Knowledge Base

Articles list

Cloud Storage API

Cloud Storage gives developers the ability to integrate with third-party apps and sites. Operations with Cloud Storage occur based on REST API.

The API is intended for applications working with user files in storage or sending their own data to storage. API interactions are performed using standard HTTP requests. All currently available API requests, their format, and responses are described in this documentation. The following operations can be performed using the API:

  • retrieve information on the current account, containers, and files
  • create and delete containers
  • upload and download files
  • copy, move, and delete files
  • set storage limits for files
  • create third-party upload links
  • manage file versions
  • create users and assign access permissions

URL Format

API Access

To successfully process API requests, you must:

  • be a registered Selectel user
  • have an adequate Storage Balance
  • have a login and password for accessing storage
  • have an access key (token), which will be included in all requests 

API Authentication

In this section you will find a description of authentication methods and how to retrieve an API token.

When using all three mthods, please note the following:

  • Tokens are valid for 24 hours.
  • 24 hours after the latest token has been received, the API will return a 401 code and a new token will have to be retrieved.
  • If a token is requested 12 hours after the last authentication, it will be updated and the previously received token will be become invalid.

Protocol v1 Authentication

Request example

curl -i https://api.selcdn.ru/auth/v1.0 -H "X-Auth-User:000000" -H "X-Auth-Key: pas$W0rD"

A successful request will return a 204 code (No Content).

Response example

HTTP/1.1 204 No Content
Content-Type: text/plain; charset=utf-8
X-Storage-Token: ec01a5f65efa70234bba6d86187173d5
X-Content-Type-Options: nosniff
X-Expire-Auth-Token: 76134
X-Auth-Token: eв01a5f65efa70234bb46а86189073d5
X-Storage-Url: https://api.selcdn.ru/v1/SEL_ХХХХХ
Date: Wed, 04 May 2016 11:55:32 GMT

Request parameters

Request

URI

Header

Description

GET

https://api.selcdn.ru/auth/v1.0

  • X-Auth-User — account number

  • X-Auth-Key — storage password

Returns an authentication key (token) for accessing Cloud Storage via API, which will need to be included in all subsequent requests

Important! Your password for accessing Cloud Storage is shown on this page.

Reponse parameters

Parameters

Value

X-Expire-Auth-Token

period before authorization key expires (sec.)

X-Storage-URL

URL for accessing storage

X-Auth-Token

authorization key

X-Storage-Token

authorization key (matches previous parameter).

Protocol v2 Authentication 

Request example

curl -i -X POST https://api.selcdn.ru/v2.0/tokens -H 'Content-type: application/json' -d '{"auth": {"passwordCredentials": {"username": "00000", "password": "pA$sW0rD"}}}'

Response example

HTTP/1.1 200 OK
Content-Length: 423
Content-Type: application/json
Date: Thu, 19 May 2016 07:17:08 GMT
{"access":{"token":{"id":"49a049462d6943d55b2ccc85abd5fdae","expires":"2016-05-20T13:12:45\n","tenant":{"id":"00000","name":"00000"}},"user":{"id":"00000","name":"00000","roles":[]},"serviceCatalog":[{"endpoints":[{"region":"common","adminURL":"https://api.selcdn.ru/v1/SEL_00000","internalURL":"https://api.selcdn.ru/v1/SEL_0000","publicURL":"https://api.selcdn.ru/v1/SEL_00000"}],"type":"object-store","name":"swift"}]}}

Protocol v3 Authorization

curl -i  https://api.selcdn.ru/v3/auth/tokens -XPOST -d '{"auth": { "identity": { "methods": ["password"], "password": { "user": { "id": "00000", "password": "pas$sW0rD"}}}}}'
HTTP/1.1 200 OK
Content-Length: 807
Content-Type: application/json
X-Subject-Token: 614ed749fba45aa218d1ba68c7c83411
Date: Fri, 20 May 2016 12:56:36 GMT
{"token":{"expires_at":"2016-05-21T09:27:53.8459900Z","issued_at":"2016-05-20T15:56:36.8459900Z","methods":["password"],"project":{"domain":{}},"Catalog":[{"endpoints":[{"id":"614ed749fba45aa218d1ba68c7c83411","region_id":"RegionOne","url":"https://api.selcdn.ru/v1/SEL_43371","region":"RegionOne","interface":"public"},{"id":"614ed749fba45aa218d1ba68c7c83411","region_id":"RegionOne","url":"https://api.selcdn.ru/v1/SEL_43371","region":"RegionOne","interface":"admin"},{"id":"614ed749fba45aa218d1ba68c7c83411","region_id":"RegionOne","url":"https://api.selcdn.ru/v1/SEL_43371","region":"RegionOne","interface":"internal"}],"type":"object-store","name":"swift","id":""}],"user":{"id":"614ed749fba45aa218d1ba68c7c83411","name":"43371","domain":{"id":"default","name":"Default","links":{}}},"audit_ids":[""]}}

Temporary Tokens

For users who do not have their own account, Cloud Storage can be accessed using temporary tokens, These tokens are valid for a limited time and can only be used for accessing specific containers, and not the whole account.


Request

URI

Header

Description

GET

https://api.selcdn.ru/auth/v1.0

  • X-Auth-Token — main user authentication key

  • X-Container — the container to create a temporary token for;

  • X-Expire-After — expiration period for the temporary token in seconds

Returns a temporary token for accessing Cloud Storage

Request example

curl -i https://api.selcdn.ru/v1/temptokens -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fdae" -H "X-Container: container" -H "X-Expire-After: 3600"

If the request is successfully processed, a 204 No Content code is returned. 

Response example

HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Content-Type: text/plain; charset=utf-8
X-Auth-Token: abdb173e328cc61e220300bcc3bbd7e
X-Content-Type-Options: nosniff
X-Expire-Auth-Token: 3600
X-Storage-Token: abdb173e328cc61e220300bcc3bbd7e
X-Storage-Url: https://api.selcdn.ru/v1/SEL_22302
Date: Fri, 23 Mar 2018 09:15:52 GMT

Account Operations

Retrieving Account Information 

Request example

curl -I https://api.selcdn.ru/v1/SEL_0000  -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fdae"

If the request is successfully processed, the API will return a 204 code.

Response example

HTTP/1.1 204 No Content
Content-Length: 0
X-Account-Object-Count: 6
X-Timestamp: 1374058535.42927
X-Account-Meta-Temp-Url-Key: 00000
X-Account-Bytes-Used: 484474
X-Account-Container-Count: 3
Content-Type: text/plain; charset=utf-8
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Account-Object-Count, X-Timestamp, X-Account-Meta-Temp-Url-Key, X-Account-Bytes-Used, X-Account-Container-Count

Response parameters


Parameters

Value

X-Account-Bytes-Used

total volume of data saved, in bytes

X-Account-Container-Count

number of containers

X-Account-Object-Count

total number of objects saved

Retrieiving Storage Information

Request type: HEAD

Request parameters

ParametersValue
X-Auth-Tokenauthorization key

Request example

curl -I https://xxxxx.selcdn.ru/ -H "X-Auth-Token:$token"

Response example

 


Response parameters

ParametersValue
X-Account-Bytes-Usedtotal volume of data saved, in bytes
X-Account-Container-Countnumber of containers
X-Account-Object-Counttotal number of objects saved
X-Transferred-Bytestotal amount of data downloaded from container in bytes
X-Received-Bytestotal amount of data uploaded to container in bytes

Container Operations

Retrieving Container Lists


Request

URI

Header

Description

GET

https://api.selcdn.ru/v1/SEL_xxxxx

  • X-Auth-Token — authorization key

Returns the list of available containers


 Request example

curl https://api.selcdn.ru/v1/SEL_22302  -H "X-Auth-Token:49a049462d6943d55b2ccc85abd5fdae"

Response example

container1
container2
container3
сontainer4

Resquest example

curl -i https://77218.selcdn.ru/?format=json  -X GET -H "X-Auth-Token: $token"


Response example

HTTP/1.1 200 OK
Date: Tue, 28 Oct 2014 11:08:54 GMT
Server: Selectel_Storage/1.0
X-Account-Object-Count: 6
X-Timestamp: 1374058535.42927
X-Account-Meta-Temp-Url-Key: c5zzs2wa
X-Account-Bytes-Used: 484474
X-Account-Container-Count: 3
Content-Type: application/json; charset=utf-8
Accept-Ranges: bytes
Content-Length: 300
X-Received-Bytes: 345102605
X-Transfered-Bytes: 54907061
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Account-Object-Count, X-Timestamp, X-Account-Meta-Temp-Url-Key, X-Account-Bytes-Used, X-Account-Container-Count, X-Received-Bytes, X-Transfered-Bytes
Expires: 0
Pragma: no-cache
Cache-Control: no-cache, no-store, must-revalidate
[{"count": 1, "name": "test2", "rx_bytes": 363, "tx_bytes": 1006, "type": "public", "bytes": 363}, {"count": 1, "name": "upload", "rx_bytes": 0, "tx_bytes": 0, "type": "private", "bytes": 363}, {"count": 4, "name": "yellow", "rx_bytes": 484666, "tx_bytes": 264846, "type": "public", "bytes": 483748}]

Response parameters


ParametersValue
X-Account-Container-Countnumber of containers
X-Account-Object-Counttotal number of objects saved
X-Transferred-Bytestotal amount of data downloaded from container in bytes
X-Received-Bytestotal amount of data uploaded to container in bytes

These requests can be used to retieve information on 10,000 containers. If you have more containers, then you will have to use addition requests with the marker parameter.

Creating a New Container


Request

URI

Header

Description

PUT

https://api.selcdn.ru/v1/SEL_xxxxx/container

  • X-Auth-Token — authorization key

  • X-Container-Meta-Type — container type: public or private

  • X-Container-Meta-Some — container metadata

Creates a container based on the parameters sent in the request


Request example

curl -i -XPUT https://api.selcdn.ru/v1/SEL_0000/new_container -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fdae" -H "X-Container-Meta-Type: public" -H "X-Container-Meta-Some: my test container"

Response example

HTTP/1.1 201 Created
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Backend-Timestamp, Etag, Last-Modified, X-Object-Manifest, X-Timestamp
Content-Length: 0
Content-Type: text/html

Retrieving Container Information


Request

URI

Header

Description

HEAD

https://api.selcdn.ru/v1/SEL_xxxxx/container

  • X-Auth-Token — authorization key

Returns information on the given container

Response parameters

Parameters

Value

X-Container-Object-Count

number of objects in container

X-Container-Bytes-Used

total volume of all saved objects, in bytes

X-Container-Meta-Type

container type (public or private)

X-Container-Meta-Some

container metadata

X-Container-Domains

domains bound to container

X-Transferred-Bytes

total amount of data downloaded from container in bytes

X-Received-Bytes

total amount of data uploaded to container in bytes


Request example

curl -I https://api.selcdn.ru/v1/SEL_22302/t-rex -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fdae"

If the request is successfully processed, the API will return a 204 code.

Response example

HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Content-Length,Date,X-Container-Domains,X-Backend-Delete-Timestamp,X-Timestamp,X-Container-Meta-Type,X-Backend-Status-Changed-At,X-Backend-Storage-Policy-Index,X-Container-Object-Count,X-Backend-Put-Timestamp,X-Container-Bytes-Used,Content-Type,X-Backend-Timestamp,X-Put-Timestamp
Content-Type: text/plain; charset=utf-8
Date: Wed, 14 Mar 2018 08:43:43 GMT
X-Backend-Delete-Timestamp: 0000000000.00000
X-Backend-Put-Timestamp: 1445521637.35495
X-Backend-Status-Changed-At: 1445521364.56786
X-Backend-Storage-Policy-Index: 0
X-Backend-Timestamp: 1445521364.51371
X-Container-Bytes-Used: 2455570
X-Container-Domains:
X-Container-Meta-Type: gallery
X-Container-Object-Count: 9
X-Put-Timestamp: 1445521637.35495
X-Timestamp: 1445521364.51371

Setting, Changing, and Deleting Container Metadata


Request

URI

Header

Description

PUT

https://api.selcdn.ru/v1/SEL_xxxxx/container

  • X-Auth-Token — authorization key

  • X-Container- Meta-Type

  • X-Container-Meta-Some — container metadata

Sets metadata sent in the X-Container-Meta-Some header for the given container

POST

https://api.selcdn.ru/v1/SEL_xxxxx/container

  • X-Auth-Token — authorization key

  • X-Container-Meta-Some — container metadata

Replaces existing metadata with new metadata in the X-Container-Meta-Some header

POST

https://api.selcdn.ru/v1/SEL_xxxxx/container

  • X-Auth-Token — authorization key

  • X-Remove-Container-Meta-Some — container metadata to be deleted

Deletes metadata in the X-Remove-Container-Meta-Some header


Example request

curl -i -XPUT {storage_url}/{container_name} -H "X-Auth-Token: $token" -H "X-Container-Meta-Type: gallery"

Creating a Photo Gallery


Request

URI

Header

Description

PUT

https://api.selcdn.ru/v1/SEL_xxxxx/container

  • X-Auth-Token — authorization key

  • X-Container-Meta-Type: gallery — container type (in this gase — gallery)

Activates the function to view images in a gallery


Request example

curl -i https://api.selcdn.ru/v1/SEL_00000/container  -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fdae" -H "X-Container-Metatype: gallery"

If the request is processed successfully, the API will return a 204 code.

Example response

HTTP/1.1 202 Accepted
Content-Length: 76
Content-Type: text/html; charset=UTF-8
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers:

Retrieving a Container File List 

Request parameters

Request

URI

Header

Description

GET

https://api.selcdn.ru/v1/SEL_xxxxx/container

  • X-Auth-Token — authorization key

Returns a list of files stored in the given container

Request example

curl -i https://api.selcdn.ru/v1/SEL_00000/container  -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fdae"

Response example

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Backend-Storage-Policy-Index,X-Backend-Status-Changed-At,X-Put-Timestamp,X-Container-Meta-Type,X-Timestamp,X-Backend-Delete-Timestamp,X-Backend-Timestamp,X-Backend-Put-Timestamp,X-Container-Bytes-Used,Content-Length,X-Container-Object-Count,Content-Type,Date
Content-Length: 120
Content-Type: text/plain; charset=utf-8
Date: Wed, 14 Mar 2018 09:11:28 GMT
X-Backend-Delete-Timestamp: 0000000000.00000
X-Backend-Put-Timestamp: 1445521637.35495
X-Backend-Status-Changed-At: 1445521364.56786
X-Backend-Storage-Policy-Index: 0
X-Backend-Timestamp: 1445521364.51371
X-Container-Bytes-Used: 2455570
X-Container-Meta-Type: gallery
X-Container-Object-Count: 9
X-Put-Timestamp: 1445521637.35495
X-Timestamp: 1445521364.51371
File1
File2
File3
File4

Additional Query Parameters

Requests for retrieving file lists may use additional query parameters, for example:

curl -I https://api.selcdn.ru/v1/SEL_00000/container/?format=json -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fdae"

After processing this command, we'll be returned a list of files in json format. In place of json, we can indicate a different format for our list  xml:

curl -I https://api.selcdn.ru/v1/SEL_00000/container/?format=xml -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fdae"

With the limit parameter, we can assign a specific number of files that will be included in our list. This may be useful when working with containers that store a large number (thousands or even tens of thousands) of objects:

curl -I https://api.selcdn.ru/v1/SEL_00000/container/?limit=20 -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fdae"

The response to this request will only return the first 20 files. The list will not contain any information on the other files.

The marker parameter lets us assign a file name for where the list should start:

curl -i https://api.selcdn.ru/v1/SEL_00000/container/?marker=file3 -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fdae"

The response to this request will only include files in our container after the file3. Files normally listed before this file will not be shown.

With the prefix parameter, the list will include files that start with a given letter combination:

curl -i https://api.selcdn.ru/v1/SEL_00000/container/?prefix=my_ -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fdae"

With the delimiter parameter, we can print out only the part of file name that occurs before a given symbol:

curl -i https://api.selcdn.ru/v1/SEL_00000/container/?delimiter=.

After this command, we will only see the portion of the file name before the period (just the name without the extension).

Deleting Containers

Important! Before deleting a container, all files contained within must first be deleted. If a container has even one file, it will not be deleted.

Request

URI

header

Description

DELETE

https://api.selcdn.ru/v1/SEL_xxxxx/container

  • X-Auth-Token — authorization key

Deletes the given container

Request example

curl -i  https://api.selcdn.ru/v1/SEL_00000/container/ -X DELETE -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fda"

If the request is successfully processed, the API will return a 204 code.

Response example

HTTP/1.1 204 No Content
content-length: 0
content-type: text/html; charset=UTF-8
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers:

Downloading Containers and Folders as a Zip Archive

The contents of a folder or public container may be downloaded to the local machine as a single zip archive. To download the contents of a container as a zip archive, you need to add the relevant link to the download-all-as-zip=[archive name] query parameter; for example:

wget https://api.selcdn.ru/v1/SEL_00000/container/?download-all-as-zip=container.zip

Private containers and their contents cannot be downloaded as a zip file.

Please note that archived files are not compressed: this function was designed to simplify downloads and not to reduce traffic. 

Archives should contain no more than 10,000 files, otherwise the API will return an error.

Managing Files

Downloading Files from Containers


Request

URI

Header

Description

GET

https://api.selcdn.ru/v1/SEL_xxxxx/container/file

  • X-Auth-Token — authorization key (necessary only when downloading from a private container; downloads from public containers can occur without a token).

Standard HTTP headers as described in RFC2616 may also be included in requests:

  • If-Match

  • If-None-Match;

  • If-Modified-Since;

  • If-Unmodified-Since

Downloads the given file to the local machine

Request example

curl -O https://api.selcdn.ru/v1/SEL_00000/images/image1.png

Uploading Files to Containers


Request

URI

Header

Description

PUT

https://api.selcdn.ru/v1/SEL_xxxxx/container/file

  • X-Auth-Token — authorization key

  • X-Delete-At —  time when file will be deleted (in Unix Timestamp format)

  • X-Delete-After — time (in seconds) before a file is deleted

  • Etag — MD5 hash of uploaded file

  • X-Object-Meta — metadata of uploaded object

Uploads an object to the given container 

Request example

curl -i -XPUT https://api.selcdn.ru/v1/SEL_00000/new_container/file  -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fda" -H "X-Delete-After: 180"  -T "file"

If the request is successfully processed, the API will return a 201 code.

Response example


HTTP/1.1 100 Continue
HTTP/1.1 201 Created
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Backend-Timestamp, Etag, Last-Modified, X-Object-Manifest, X-Timestamp
Content-Length: 0
Content-Type: text/html
Etag: b65ad34618e410d9d8bf624d61f8a980
Date: Thu, 15 Mar 2018 07:31:32 GMT

Extracting Archives

Archives in *.tar, *.tar.gz and *.gzip format can be automatically extracted after being uploaded to storage. This can be done by sending a PUT request with an additional extract-archive query parameter to the container address:

сurl -i -XPUT  https://api.selcdn.ru/v1/SEL_00000/new_container/archive.tar.gz/?extract-archive=tar.gz  -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fda" -T "archive.tar.gz"

Managing HTTP File Headers

HTTP headers can be set for all files located in storage. Headers are used for managing caching on the client side (and on intermediate proxy servers), as well as for processing cross-origin requests (CORS).

The following headers are supported:

  • Cache-Control

  • Expires

  • Origin

  • Access-Control-Allow-Origin

  • Access-Control-Max-Age

  • Access-Control-Allow-Methods

  • Access-Control-Allow-Credentials

  • Access-Control-Expose-Headers

  • Access-Control-Request-Headers

  • Access-Control-Request-Method

  • Content-Disposition (only for end files)

  • Strict-Transport-Security (only for containers)

Request example

curl -i -XPOST  https://api.selcdn.ru/v1/SEL_xxxxx/container -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fda" -H "X-Container-Meta-Access-Control-Request-Method: HEAD, GET" \    -H "X-Container-Meta-Cache-Control: public" -H "X-Container-Meta-Strict-Transport-Security: max-age=31536000; includeSubDomains"

If the request is successfully processed, the API will return a 201 code.

Response example

HTTP/1.1 202 Accepted
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Backend-Timestamp, Etag, Last-Modified, X-Object-Manifest, X-Timestamp
Content-Length: 76
Content-Type: text/html
Date: Mon, 26 Mar 2018 06:59:45 GMT

Accepted

The request is accepted for processing.

Large Object Support

There are no size limits for files uploaded to storage. However, it is not advisable to keep single files larger than 1 GB in storage; in this case, it's recommended to use segment uploading.

There are two techniques for uploading in segments: dynamic and static.

Dynamic Uploads

A dynamic upload breaks the object into segments, and then creates a manifest. This is an empty file in the X-Object-Manifest header, which contains an identifier for the container that all of the segments were uploaded to.

Segments should be uploaded before creating and updating the manifest: the object in this case will not be available for download until all of the segments have been uploaded.

Example

curl -X PUT -H 'X-Auth-Token: 49a049462d6943d55b2ccc85abd5fda' \    https://api.selcdn.ru/v1/SEL_00000/new_container/big_object/00000001 --data-binary '1' curl -X PUT -H 'X-Auth-Token: 49a049462d6943d55b2ccc85abd5fda' \    https://api.selcdn.ru/v1/SEL_00000/new_container/big_object/00000002 --data-binary '2' curl -X PUT -H 'X-Auth-Token: 49a049462d6943d55b2ccc85abd5fda' \ https://api.selcdn.ru/v1/SEL_00000/new_container/big_object/00000003 --data-binary '3'


Manifest example

curl -X PUT -H 'X-Auth-Token:49a049462d6943d55b2ccc85abd5fda' \    -H 'X-Object-Manifest: container/myobject/' \    https://api.selcdn.ru/v1/SEL_00000/new_container/big_object/ --data-binary '' 

Static Uploads

For static uploads, a static manifest has to be created, which shows the path to the segments, their control sum (Etag) and size. The manifest is saved in a special file.

Manifest example

[{"path": "/cont/object",  "etag": "etagoftheobjectsegment",  "size_bytes": 10485760, }, ...]

To manifest file has to be uploaded to storage using a PUT request with the query parameter ?multipart-manifest=put and the header X-Static-Large-Object: True .

To retrieve the manifest file, a GET request with the query parameter ?multipart-manifest=get has to be executed.

All of the segments and manifest file can be deleted by sending a DELETE request with the query parameter ?multipart-manifest=delete.

Setting File Expirations

Request

URI

Header

Description

PUT

https://api.selcdn.ru/v1/SEL_xxxxx/container

  • X-Auth-Token — authorization key

  • X-Container-Meta-Default-Delete-After — expiration period for all files in container (in seconds)

Sets an expiration period for files in a given container. At the end of this period, all files in the container will be automatically deleted.


Request example

curl -i -XPUT https://api.selcdn.ru/v1/SEL_0000/container  -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fda" -H "X-Container-Meta-Default-Delete-After: 300"

If the request is successfully processed, the API will return a 202 code.

Response example

HTTP/1.1 202 Accepted
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Backend-Timestamp, Etag, Last-Modified, X-Object-Manifest, X-Timestamp
Content-Length: 76
Content-Type: text/html
Date: Thu, 15 Mar 2018 09:13:56 GMT

Setting Metadata

Request

URI

Header

Description

PUT

https://api.selcdn.ru/v1/SEL_xxxxx/container/file

  • X-Auth-Token — authorization key

  • X-Object-Meta-Some —  any additional file information

Adds metadata transferred in the X-Object-Meta-Some header to a file


Request example

curl -i -XPUT  https://api.selcdn.ru/v1/SEL_00000/new_container/file  -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fda" -H "X-Object-Meta-Some: metadata"

If the request is successfully processed, the API will return a 201 code.

Response example

HTTP/1.1 201 Created
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Backend-Timestamp, Etag, Last-Modified, X-Object-Manifest, X-Timestamp
Content-Length: 0
Content-Type: text/html
Etag: d41d8cd98f00b204e9800998ecf8427e
Date: Mon, 19 Mar 2018 06:48:55 GMT

Copying Files in Storage

Method 1

Request

URI

Header

Description

PUT

https://api.selcdn.ru/v1/SEL_xxxxx/new_location/path to the container or folder where file should be copied/

  • X-Auth-Token — authorization key

  • X-Copy-From — path to file to be copied

Copies a file from one location to another

Request example

curl -i -X PUT https://api.selcdn.ru/v1/SEL_00000/container2/file -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fda" -H "X-Copy-From: /container1/file

Response example

HTTP/1.1 201 
Created etag: 0f343b0931126a20f133d67c2b018a3b 
X-Copied-From: new_container/new_object 
X-Copied-From-Last-Modified: Mon, 27 May 2013 13:16:49 GMT 
Last-Modified: Tue, 28 May 2018 06:30:51 GMT

Method 2

Request

URI

Header

Description

СOPY

https://api.selcdn.ru/v1/SEL_xxxxx/container/file/path to the file to be copied/

  • X-Auth-Token — authorization key

  • Destination — path to container and folder where file will be copied

Copies a file from one location to another

Request example

curl -i -X COPY https://api.selcdn.ru/v1/SEL_00000/container1/file   -H "X-Auth-Token:49a049462d6943d55b2ccc85abd5fda"    -H "Destination: /container2/file"

Response example

HTTP/1.1 201 Created etag: 0f343b0931126a20f133d67c2b018a3b X-Copied-From: container1/file
X-Copied-From-Last-Modified: Mon, 27 May 2013 13:16:49 GMT Last-Modified: Tue, 28 May 2013 06:30:51 GMT

Creating Symbolic Links to Files

When using Cloud Storage as a backend for public services, it often becomes necessary to delineate file access; for example, making files in a private container accessible to a wide number of users.

For these particular situations, symbolic links can be created in storage. These links can be password protected or have expirations.

Request

URI

Header

Description

PUT

https://api.selcdn.ru/v1/SEL_xxxxx/container/file

/the address indicates the container where the symbolic link will be saved and the name the link will be saved as/

  • X-Auth-Token — authorization key;

  • Content-Type —  symbolic link type (x-storage/onetime-symlink — one-time link, x-storage/symlink+secure — password-protected link, x-storage/onetime-symlink+secure — one-time password-protected link);

  • X-Object-Meta-Location — quoted path to an object in storage;

  • X-Object-Meta-Delete-At — link expiration date (in Unix Timestamp format);

  • X-Object-Meta-Link-Key — hash password (for password-protected links);

  • Content-Disposition — shows what to do with a linked file : open in browser (inline) or download to local machine (attachment)

Creates a symbolic link with parameters assigned int he request.

Request example

curl -i -XPUT https://api.selcdn.ru/v1/SEL_00000/new_container/new_link   -H "X-Auth-Token: $token" -H "Content-Type: x-storage/symlink" -H "X-Object-Meta-Location: /new_container/new_object"  -H "X-Object-Meta-Link-Key: b6589fc6ab0dc82cf12099d1c2d40ab994e8410c" -H "Content-Length: 0"

Response example

HTTP/1.1 201 Created
> etag: d41d8cd98f00b204e9800998ecf8427e
> Last-Modified: Mon, 27 May 2013 13:34:34 GM

Special links can be created to allow third-parties to download your files (including from private containers). Links can be created with an API request.

Before we generate a link, we have to establish a secret key.

curl -i -XPOST http://xxx.selcdn.ru/   -H "X-Auth-Token: $tOkeN -H X-Account-Meta-Temp-URL-Key: $key"

Only users who know the secret key can access files from the generated links.

import hmac
from hashlib import sha1
from time import time
 
# access method (always GET)
method = "GET"
 
# reference valid 60 seconds
expires = int(time()) + 60
 
# the path to the file in the repository, always with the container specified
path = "/container/dir/file"
 
# secret key
link_secret_key = "secret_word"
 
# generate access key
hmac_body = '%s\n%s\n%s' % (method, expires, path)
 
# access key
sig = hmac.new(link_secret_key, hmac_body, sha1).hexdigest()

We will have to include this key in the link:

http://xxx.selcdn.ru/container/dir/file?temp_url_sig=3f512dfed32111d6e742afc5522076c0621951cc&temp_url_expires=13909142
  • xxx.selcdn.ru — base domain
  • temp_url_sig — access key
  • temp_url_expires — ime when the link expires (unixtime)

If a domain is attached to the continer, then it can be given in the link. The container name does not need to be given in this case:

http://my.domain/dir/file?temp_url_sig=3f512dfed32111d6e742afc5522076c0621951cc&temp_url_expires=1390914227

The Content-Disposition header is supported for managing data returned from the link. For this to work, the filename parameter must be added with the following value:

http://xxx.selcdn.ru/container/dir/file?temp_url_sig=3f512dfed32111d6e742afc5522076c0621951cc&temp_url_expires=1390914227&filename=Other+file+name.doc

The secret key can be changed. Whenever the key is changed, all previously generated links will stop working.

Creating Upload Links (sendmefile)

Request

URI

Header

Description

PUT

https://api.selcdn.ru/v1/SEL_xxxxx/container/upload

  • X-Auth-Token — authorization key

  • Content-Type — link properties (x-storage/sendmefile+inplace — uploads only one file with the given filename, x-storage/sendmefile+timepostfix —- uploads files and adds a timestamp to the filename with the upload time, x-storage/sendmefile+autopostfix — uploads files and adds a unique identifier to the filename, x-storage/sendmefile+folderday — uploads files to a folder whose name is the upload date in the format yyyy-dd-mm, x-storage/sendmefile+folderhour — uploads files to a folder whose name is the upload date and time in the format dd-mm hh:min min, x-storage/sendmefile+folderuniq — )

  • X-Object-Meta-Sendmefile-Disable-Web  —  enables (yes)/disables (no) the web interface for uploading files; the value for this header is set to yes by default (interface enabled);

  • X-Object-Meta-Sendmefile-Max-Size — maximum size for an uploaded file (in bytes)

  • X-Object-Meta-Sendmefile-Allow-Overwrite —  allows (yes) or prohibits (no) overwriting files if reuploaded (overwriting files is prohibited by default)

  • X-Object-Meta-Sendmefile-Ignore-Filename — allow (yes) files to be automatically renamed according to the given setting

  • X-Object-Meta-Sendmefile-Secret —  hash password (for password-protected links)

  • X-Filename  — name that will be given to the uploaded file

  • X-Sendmefile-Session-Id —  upload session id

Creates a link from which third-party users can upload files to the given container

Request example

curl -i -XPUT
https://api.selcdn.ru/v1/SEL_xxxxx/container/upload
-H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fda"    -H "Content-Type: x-storage/sendmefile+inplace"     -H "X-Object-Meta-Sendmefile-Max-Size: 52428800" -H "X-Object-Meta-Sendmefile-Expire: 14400"   -H "X-Object-Meta-Sendmefile-Secret: 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8" -d "Explanatory text for upload page"

Deleting Files

Request

URI

Header

Description

DELETE

https://api.selcdn.ru/v1/SEL_xxxxx/container/file

  • X-Auth-Token — authorization key

Deletes the given file

Request example

curl -i  https://api.selcdn.ru/v1/SEL_00000/container/file -X DELETE -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fda"

If the request is successfully processed, the API will return a 204 code.

Response example

HTTP/1.1 204 No Content
content-length: 0
content-type: text/html; charset=UTF-8
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers:

Versioning

Electronic documents usually undergo many changes. Often not only the latest version of the document needs to be saved, but several previous versions as well. To facilitate this, Cloud Storage supports versions.

Request

URI

Header

Description

PUT

https://api.selcdn.ru/v1/SEL_xxxxx/container

  • X-Auth-Token — authorization key

  • X-Versions-Location — name of container where versions will be saved

Activates versioning for the given container. Versions of all objects will be saved in the container whose name is given in the X-Versions-Location header

Request example

curl -i  https://api.selcdn.ru/v1/SEL_00000/container1/
-XPUT -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fda" -H "X-Versions-Location: container2"

If the request is processed successfully, the API will return a 202 code.

Response example

HTTP/1.1 202 Accepted Content-Length: 76 
Content-Type: text/html; charset=UTF-8 
Access-Control-Allow-Origin: * Access-Control-Expose-Headers: Expires: 0 Pragma: no-cache 
Cache-Control: no-cache, no-store, must-revalidate

Setting Limits

Setting Limits for Containers

Request

URI

Header

Description

POST

https://api.selcdn.ru/v1/SEL_xxxxx/container/

  • X-Auth-Token — authorization key

  • X-Container-Meta-Quota-Bytes —maximum allowable amount of data in container (in bytes)

  • X-Container-Meta-Quota-Count — maximum allowable number of files and folders in a container

Sets the limit sent in the X-Container-Meta-Quota-Byte and X-Container-Meta-Quota-Count headers on the given container

Request example

curl -i -XPOST https://api.selcdn.ru/v1/SEL_00000/container/  -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fda"   -H "X-Container-Meta-Quota-Bytes: 52428800" -H "X-Container-Meta-Quota-Count: 1000"

If the request is successfully processed, the API will return a 202 code.

Response example

HTTP/1.1 202 Accepted
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Backend-Timestamp, Etag, Last-Modified, X-Object-Manifest, X-Timestamp
Content-Length: 76
Content-Type: text/html
Date: Mon, 19 Mar 2018 07:41:24 GMT

Accepted

The request is accepted for processing.

Setting Overall Account Limits

Request

URI

Header

Description

POST

https://api.selcdn.ru/v1/SEL_xxxxx/

  • X-Auth-Token — authorization key

  • X-Container-Meta-Quota-Bytes — maximum allowable amount of data in container (in bytes)

  • X-Container-Meta-Quota-Count maximum allowable number of files and folders in a container

Sets limits sent in the X-Container-Meta-Quota-Bytes and X-Container-Meta-Quota-Count headers.Limits will be effective on the account level for all files and folders

Request example

curl -i -XPOST https://api.selcdn.ru/v1/SEL_00000 -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fda"   -H "X-Container-Meta-Quota-Bytes: 52428800" -H "X-Container-Meta-Quota-Count: 1000"

Response example

HTTP/1.1 202 Accepted
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Backend-Timestamp, Etag, Last-Modified, X-Object-Manifest, X-Timestamp
Content-Length: 76
Content-Type: text/html
Date: Mon, 19 Mar 2018 07:41:24 GMT

Accepted

The request is accepted for processing.

Managing Users

Viewing User List

Request

URI

Header

Description

GET

https://api.selcdn.ru/v1/users

  • X-Auth-Token — authorization key

Prints out a list of users for the current account

Request example
curl -i https://api.selcdn.ru/v1/users  -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fd’

If the request is successfully processed, the API will return a 200 code.

Response example

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Type: text/plain; charset=utf-8
Date: Mon, 19 Mar 2018 09:01:22 GMT
Content-Length: 80
main_user (true)
main_user (true)
user1 (true)
user2 (true)
user3 (true)

Adding New Users

Request

URI

Header

Description

PUT

https://api.selcdn.ru/v1/users/username

  • X-Auth-Token — authorization key

  • Х-Auth-Key —  password for new user

  • X-User-Active — user status (on — active, off— inactive)

  • X-User-ACL-Container-R — list of containers that new user only has read access to

  • X-User-ACL-Container-W — list of containers that new user has write access to

  • X-Store-Password — shows whether or not to save the new user's password in the open base (similar to "Save password on Selectel servers" in the control panel)

Creates a new user with the given account settings

Request example

curl -i https://api.selcdn.ru/v1/users/my_test_user  -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fd’ -H "X-Auth-Key: 123456" -H "X-User-ACL-Containers-W: container1, container2, container3" -H "X-User-ACL-Containers-R: container4" -H "X-User-Store-Password: yes" -H "X-User-Active: on"

If the request is successfully processed, the API will return a  201 code.

Response example

HTTP/1.1 201 Created
Content-Type: text/html; charset=UTF-8
Content-Length: 0

Deleting Users

Request

URI

Header

Description

DELETE

https://api.selcdn.ru/v1/users/username

  • X-Auth-Token — authorization key

Deletes the given user

Request example

curl -i -X DELETE https://api.selcdn.ru/v1/users/my_test_user  -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fd’

If the request is successfully processed, the API will return a 201 code.

Response example

HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Mon, 19 Mar 2018 10:04:25 GMT

Changing the Main User's Password

Request

URI

Header

Description

POST

https://api.selcdn.ru/v1/users/

  • X-Auth-Token — authorization key

  • X-Auth-Key — new password

  • X-Store-Password — shows whether or not to save the new user's password in the open base (similar to "Save password on Selectel servers" in the control panel)

Changes the password of the primary user to the password given in the X-Auth-Key header

Request example

curl -i -XPOST https://api.selcdn.ru/v1/users -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fd" -H "X-Auth-Key: pA$sW0rD" -H "X-User-Store-Password: yes"

If the request is successfully processed, the API will return a 204 code.

Response example

HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Mon, 19 Mar 2018 10:30:59 GMT

Managing Domains

Domains can be bound to containers in storage. All of these operations are performed through the API.

Default Domains

Every Cloud Storage user is automatically given a set of domains by default, which can be used for accessing objects in any container:

A domain in the format xxxx.akamaihd.net can be ordered over ticket system. These domains grant HTTPS acces to objects in containers over the CDN cache of our partner Akamai.

Retrieving List of Bound Domains

Request

URI

Header

Description

GET

https://api.selcdn.ru/v1/domains

  • X-Auth-Token — authorization key

Returns a list of domains

Request example

curl -i https://api.selcdn.ru/domains -H "X-Auth-Token:  49a049462d6943d55b2ccc85abd5fd"

If the request is successfully processed, the API will return a 200 code.

Response example

HTTP/1.1 200 OK
Content-Length: 69
Content-Type: text/html
Date: Mon, 16 May 2016 07:36:35 GMT
Base Domains:
00000.selcdn.ru
00000.selcdn.com
Containers Domains:
container1  domain1.ru
container2  domain1.ru

Binding Domains

Request

URI

Header

Description

POST

https://api.selcdn.ru/v1/SEL_00000/container

  • X-Auth-Token — authorization key

  • X-Add-Container-Domains — domain name to attach to container

Binds a domain given in the X-Add-Container-Domains header to a container

Request example

curl -i https://api.selcdn.ru/v1/container  -XPOST -H "X-Add-Container-Domains: domain1.ru" -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fd"

If the request is successfully processed, the API will return a 204 code.

Response example

HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Backend-Timestamp, Etag, Last-Modified, X-Object-Manifest, X-Timestamp
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Tue, 20 Mar 2018 12:09:38 GMT

Deleting Domains

Request

URI

Header

Description

POST

https://api.selcdn.ru/v1/SEL_00000/container

  • X-Auth-Token — authorization key

  • X-Remove-Container-Domains — name of domain to be deleted (detached from container)

Deletes the domain given in the X-Remove-Container-Domains container

Request example

curl -i -XPOST https://api.selcdn.ru/v1/SEL_0000/container -XPOST -H "X-Remove-Container-Domains: domain1.ru" -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fd"

If the request is successfully processed, the API will return a 204 code.

Response example

HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Backend-Timestamp, Etag, Last-Modified, X-Object-Manifest, X-Timestamp
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Tue, 20 Mar 2018 12:30:23 GMT

Editing Domain Lists

Request

URI

Header

Description

POST

https://api.selcdn.ru/v1/SEL_00000/container

  • X-Auth-Token — authorization key

  • X-Container-Domains — name of domain to be deleted (detached from container)

Deletes the domain given in the X-Remove-Container-Domains header

curl -i -XPOST https://api.selcdn.ru/v1/SEL_00000 -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fda"   -H "X-Container-Meta-Quota-Bytes: 52428800" -H "X-Container-Meta-Quota-Count: 1000"

If the request is successfully processed, the API will return a 204 code.

Response example

HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Backend-Timestamp, Etag, Last-Modified, X-Object-Manifest, X-Timestamp
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Tue, 20 Mar 2018 12:30:23 GMT

Managing Custom SSL Certificates

Retrieving List of Certificates

Request

URI

Header

Description

GET

https://api.selcdn.ru/v1/ssl

  • X-Auth-Token — authorization key

Returns a list of certificates

Request example

curl -i https://api.selcdn.ru/v1/ssl -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fd"

Retrieving Certificate Information

Request

URI

Header

Description

GET

https://api.selcdn.ru/v1/SEL_22302/ssl/cert

  • X-Auth-Token — authorization key

Returns information about the given certificate

Request example

curl -i https://api.selcdn.ru/v1/SEL_22302/ssl/cert -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fd"

Adding Certificates

Request

URI

Header

Description

PUT

https://api.selcdn.ru/v1/SEL_22302/ssl/cert

    • X-Auth-Token — authorization key

Adds a new certificate

Request example

curl -I https://api.selcdn.ru/v1/ssl/001_cert1 -H "X-Auth-Token:4 9a049462d6943d55b2ccc85abd5fd" -XPUT -T ./cert1.pem

The certificate name ({cert_name}) must be in the format 00000_cert1, where the first section (numbers) are the user account number, and the second part — any combination of symbols.

The certificate name should be unique; two certificates with the same name cannot be uploaded. 
The certificate itself and private key must be sent in the body of a request in one file.

Deleting Certificates

Request

URI

Header

Description

DELETE

https://api.selcdn.ru/v1/SEL_22302/ssl/cert

    • X-Auth-Token — authorization key

Deletes the given certificate

Purging the CDN Cache

Request

URI

Header

Description

PURGE

https://api.selcdn.ru/v1/SEL_22302/ssl/cert

  • X-Auth-Token — authorization key

  • Content-Length — request body length

Cleans the CDN cache for a page, whose address is given in the request

Request example

curl -i -X PURGE https://api.selcdn.ru/v1/cdn -H "X-Auth-Token: 4 9a049462d6943d55b2ccc85abd5fd" -d $'https://00000.selcdn.com/container/file'

If the request is successfully processed, the API will return a 200 code.

Response example

HTTP/1.1 200 OK
Date: Mon, 16 May 2016 09:45:15 GMT
Content-Length: 268
Content-Type: text/plain; charset=utf-8
{"estimatedSeconds": 5, "progressUri": "/ccu/v2/purges/e4561042-1b4a-11e6-9024-f3cf5304c77a", "purgeId": "e4561042-1b4a-11e6-9024-f3cf5304c77a", "supportId": "17PY1463391915374207-348128448", "httpStatus": 201, "detail": "Request accepted.", "pingAfterSeconds": 300}

Retrieving Logs

Request

URI

Header

Description

PURGE

https://api.selcd.ru/v1/logs

  • X-Auth-Token — authorization key

  • X-Start-Time — the logging period start in Y-m-d H:M:S format

  • X-End-Time — the logging period end in Y-m-d H:M:S format

  • X-Limit — maximum number of entries that should be returned in the response

Creates the logs container and uploads logs for the given period to it

Request example

curl -i -XPOST https://api.selcdn.ru/v1/logs -H "X-Auth-Token: 49a049462d6943d55b2ccc85abd5fdae" -H "X-Start-Time: 2016-02-02 09:00:00" -H "X-End-Time: 2016-05-02 12:00:00"

If the request is successfully processed, the API will return a 200 code.

Response example

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Date: Thu, 22 Mar 2018 09:48:58 GMT
Content-Length: 0
Content-Type: text/plain; charset=utf-8


HTTP/1.1 204 No Content Date: Tue, 28 Oct 2014 09:34:31 GMT Server: Selectel_Storage/1.0 Content-Length: 0 X-Account-Object-Count: 6 X-Timestamp: 1374058535.42927 X-Account-Meta-Temp-Url-Key: c5zzs2wa X-Account-Bytes-Used: 484474 X-Account-Container-Count: 3 Content-Type: text/plain; charset=utf-8 Accept-Ranges: bytes X-Received-Bytes: 345102605 X-Transfered-Bytes: 54907061 Access-Control-Allow-Origin: * Access-Control-Expose-Headers: X-Account-Object-Count, X-Timestamp, X-Account-Meta-Temp-Url-Key, X-Account-Bytes-Used, X-Account-Container-Count, X-Received-Bytes, X-Transfered-Bytes Expires: 0 Pragma: no-cache Cache-Control: no-cache, no-store, must-revalidate