Skip to main content

Swift (old)

warning

The URL and methods of this Swift API version will be supported until 15.09.2026. After 15.09.2026, they will be disabled. Some features will no longer be supported.

We recommend using S3 API, more details in the guide Configuring S3 after an update.

The Swift API is designed for applications that work with user files hosted in storage or send their own data to storage. Interaction with the Swift API is performed using standard HTTP requests. The documentation describes the currently available API calls and the formats of requests and responses. At this time, the following operations can be performed using the Swift API:

  • get information about the account, containers, and folders;
  • create and delete containers;
  • upload files to storage and download them;
  • copy, move, and delete files;
  • set the file retention period, etc.

URL format

The host for all API requests is https://api.selcdn.ru

After authorization, access to the storage is performed via a URL of the type: https://api.selcdn.ru/v1/SEL_ * * * **, where * **** is the user account number. The API version (v1) is also specified in the URL.

https://api.selcdn.ru/v1/SEL_ * * ***/container_name is usually used for an authorized client. For example, when working with private containers, deleting/adding objects, or working with metadata. This is the URL format in the OpenStack Object API. More details in the OpenStack documentation.

The domain * *****.selcdn.ru is a personal account domain, which can be found via the X-Storage-Url header command:

curl -i \
-H 'X-Auth-User: *****' \
-H 'X-Auth-Key: *****' \
https://api.selcdn.ru/auth/v1.0

This domain is used to distribute static content from public containers. A CNAME record is created for this domain when using custom domains linked to a container, and data distributed through this domain is cached, which speeds up content delivery.

Both options will work, but api.selcdn.ru will not be cached.

You can also find your personal account domain in the Control Panel in the container settings under the Domains.

You can get a domain using the API with the following request:

curl -i \
-H 'X-Auth-User: *' \
-H 'X-Auth-Key: *' \
https://auth.selcdn.ru/

In the future, we plan to discontinue numbered domains, so we recommend using links of the type https://api.selcdn.ru/v1/SEL_ *****..

API access

To successfully execute API requests, you must:

  • be a registered Selectel user;
  • have a sufficient account balance;
  • have a login and password for storage access;
  • obtain a unique access key (token) that will be passed in all requests.

Authorization and token acquisition

This section describes authorization methods and how to obtain a token for working with the API. Pool — ru-1, for software that requires specifying a pool (e.g., --storage-openstack-region).

When using all three methods, please note the following:

  • the token lifetime is 24 hours;
  • after 24 hours from the moment the token was last obtained, the API will return responses with code 401; in this case, the token must be obtained again;
  • if you request a token 12 hours after the last authorization, it will be updated, and the previously obtained token will become invalid.

Authorization via v1 protocol

Request example

curl -i -XGET https://api.selcdn.ru/auth/v1.0 -H "X-Auth-User: *****" -H "X-Auth-Key: $password"

Upon successful execution of the request, a response with code 204 (No Content) will be returned.

Response example

HTTP/1.1 204 No Content
Content-Type: text/plain; charset=utf-8
X-Storage-Token: $token
X-Content-Type-Options: nosniff
X-Expire-Auth-Token: *****
X-Auth-Token: $token
X-Storage-Url: https://api.selcdn.ru/v1/SEL_*****

Request parameters

Request typeURIHeadersDescription
GEThttps://api.selcdn.ru/auth/v1.0X-Auth-User — account number; X-Auth-Key — password for storage accessReturns an authorization key (token) for working with storage via API, which must be passed in all subsequent requests

The password to access the storage is specified in the Control Panel.

Response parameters

ParameterValue
X-Expire-Auth-Tokenauthorization key lifetime (in seconds)
X-Storage-URLURL for storage access
X-Auth-Tokenauthorization key
X-Storage-Tokenauthorization key (same as the previous parameter)

Authorization via v2 protocol

Request example

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

Response example

HTTP/1.1 200 OK
Content-Length: 423
Content-Type: application/json
{"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"}]}}

Authorization via v3 protocol

Request example

curl -i -XPOST https://api.selcdn.ru/v3/auth/tokens -d '{"auth": { "identity": { "methods": ["password"], "password": { "user": { "id": "*****", "password": "pA$sW0rD"}}}}}'

Response example

HTTP/1.1 200 OK
Content-Length: 807
Content-Type: application/json
X-Subject-Token: $token
{"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_*****","region":"RegionOne","interface":"public"},{"id":"614ed749fba45aa218d1ba68c7c83411","region_id":"RegionOne","url":"https://api.selcdn.ru/v1/SEL_*****","region":"RegionOne","interface":"admin"},{"id":"614ed749fba45aa218d1ba68c7c83411","region_id":"RegionOne","url":"https://api.selcdn.ru/v1/SEL_*****","region":"RegionOne","interface":"internal"}],"type":"object-store","name":"swift","id":""}],"user":{"id":"614ed749fba45aa218d1ba68c7c83411","name":"*****","domain":{"id":"default","name":"Default","links":{}}},"audit_ids":[""]}}

Account operations

Getting account information

Request example

curl -i -XGET https://api.selcdn.ru/v1/SEL_***** -H "X-Auth-Token: $token"

In case of successful execution of the request, the API returns a response with code 204.

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

Response parameters

ParameterValue
X-Account-Bytes-Usedtotal volume of stored data, bytes
X-Account-Container-Countnumber of containers
X-Account-Object-Counttotal number of stored objects

Getting storage information

Request type: GET

Request parameters

ParameterValue
X-Auth-Tokenauthorization key

Request example

curl -i -XGET https://*****.selcdn.ru/ -H "X-Auth-Token: $token"

Response example

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: *****
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

Response parameters

ParameterValue
X-Account-Bytes-Usedtotal volume of stored data, bytes
X-Account-Container-Countnumber of containers
X-Account-Object-Counttotal number of stored objects

Container operations

Getting a list of containers

Request typeURIHeadersDescription
GEThttps://api.selcdn.ru/v1/SEL_ *****X-Auth-Token — authorization tokenReturns a list of containers currently available in storage

Request example

curl https://api.selcdn.ru/v1/SEL_***** -H "X-Auth-Token: $token"

Response example

container1
container2
container3
container4

Request example

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

Response example

HTTP/1.1 200 OK

Server: Selectel_Storage/1.0
X-Account-Object-Count: 6
X-Timestamp: 1374058535.42927
X-Account-Meta-Temp-Url-Key: ******
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

ParameterValue
X-Account-Container-Counttotal number of containers in storage
X-Account-Object-Counttotal number of objects stored in containers

A single request can retrieve information about 10,000 containers. If there are more containers, additional requests with the marker parameter are required.

Creating a new container

Request parameters

Request typeURIHeadersDescription
PUThttps://api.selcdn.ru/v1/SEL_******/containerX-Auth-Token — authorization token; X-Container-Meta-Type — container type: public (public) or private (private); X-Container-Meta-Some — container metadata; X-Storage-Policy — storage policy: hot (Policy-0) by default, cold (cold)

Creates a container with the parameters specified in the request

Request example

curl -i -XPUT https://api.selcdn.ru/v1/SEL_*****/new_container -H "X-Auth-Token: $token" \
-H "X-Container-Meta-Type: public" -H "X-Container-Meta-Some: my test container"

In case of a successful request, a response with code 201 will be returned.

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

Getting information about a container

Request parameters

Request typeURIHeadersDescription
GEThttps://api.selcdn.ru/v1/SEL_******/containerX-Auth-Token — authorization tokenReturns information about the specified container

Response parameters

ParameterValue
X-Container-Object-Countnumber of objects in the container
X-Container-Bytes-Usedtotal volume of all stored objects in bytes
X-Container-Meta-Typecontainer type (public or private)
X-Container-Meta-Somecontainer metadata
X-Container-Domainsdomains linked to the container
X-Transfered-Bytestotal volume of information downloaded from the container, bytes
X-Received-Bytestotal volume of information uploaded to the container, bytes

Request example

curl -i -XGET https://api.selcdn.ru/v1/SEL_*****/t-rex -H "X-Auth-Token: $token"

Upon successful execution of the request, the API returns a response with code 204.

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 parameters

Request typeURIHeadersDescription
POSThttps://api.selcdn.ru/v1/SEL_******/containerX-Auth-Token — authorization token; X-Container-Meta-Type; X-Container-Meta-Some — container metadataSets the metadata for the specified container passed in the X-Container-Meta-Some header
POSThttps://api.selcdn.ru/v1/SEL_******/containerX-Auth-Token — authorization token; X-Container-Meta-Some — container metadataReplaces metadata with new metadata passed in the X-Container-Meta-Some header
POSThttps://api.selcdn.ru/v1/SEL_******/containerX-Auth-Token — authorization token; X-Remove-Container-Meta-Some — container metadata to be deletedDeletes metadata passed in the X-Remove-Container-Meta-Some header

Request example

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

Getting a list of files in a container

Request parameters

Request typeURIHeadersDescription
GEThttps://api.selcdn.ru/v1/SEL_******/container_nameX-Auth-Token — authorization tokenReturns a list of files located in the specified container. The list of objects is limited to 10,000. Use the marker and limit query parameters for flexible retrieval of object lists in a container.

Request example

curl -i -XGET https://api.selcdn.ru/v1/SEL_*****/container_name -H "X-Auth-Token: $token"

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

In the request to get a list of files, you can also use additional query parameters, for example:

curl -i -XGET https://api.selcdn.ru/v1/SEL_*****/container/?format=json -H "X-Auth-Token: $token"

As a result of executing this command, a list of files will be returned in json format. You can also specify another output format — xml:

curl -i -XGET https://api.selcdn.ru/v1/SEL_*****/container/?format=xml -H "X-Auth-Token: $token"

Using the limit parameter, you can set the exact number of files that will be included in the list. This opportunity is useful when working with containers that store many objects (for example, thousands or even tens of thousands):

curl -i -XGET https://api.selcdn.ru/v1/SEL_*****/container/?limit=20 -H "X-Auth-Token: $token"

As a result of executing this command, only the first 20 files will be included in the list. Information about all other files will not be in the list.

The marker parameter allows you to specify the name of the file from which the list will begin:

curl -i -XGET https://api.selcdn.ru/v1/SEL_*****/container/?marker=file3 -H "X-Auth-Token: $token"

As a result of executing this request, the list will display files that follow the file named file3. Previous files, as well as file3 itself, will not be included in the list.

Using the prefix parameter, you can include files in the list whose names start with the specified character sequence:

curl -i -XGET https://api.selcdn.ru/v1/SEL_*****/container/?prefix=my_ -H "X-Auth-Token: $token"

Using the delimiter parameter, you can display only the part of the file name that precedes a specific character, for example:

curl -i -XGET https://api.selcdn.ru/v1/SEL_*****/container/?delimiter=.

As a result of executing this command, only the part of the file names that precedes the dot (only names without extensions) will be output.

Deleting a container

Before deleting a container, you must delete all files from it. If there is at least one file in the container, deletion is impossible.

Request parameters

Request typeURIHeadersDescription
DELETEhttps://api.selcdn.ru/v1/SEL_******/containerX-Auth-Token — authorization tokenDeletes the specified container

Request example

curl -i https://api.selcdn.ru/v1/SEL_*****/container/ -X DELETE -H "X-Auth-Token: $token"

In case of success, the API returns a response with code 204.

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:

Working with files

Downloading a file from a container

Request parameters

Request typeURIHeadersDescription
GEThttps://api.selcdn.ru/v1/SEL_******/container/fileX-Auth-Token — authorization token (required only when downloading from a private container; files from public containers can be downloaded without a token). You can also use standard HTTP headers described in RFC2616 in the request: If-Match, If-None-Match, If-Modified-Since, If-Unmodified-SinceDownloads the specified file

Request example

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

To open a file in a browser, enter the command:

https://*****.selcdn.ru/container/1111_Union.patch.xml

The response will look as follows:

HTTP/2 200
accept-language: bytes
access-control-allow-origin: *
access-control-expose-headers: Content-Type,Etag,X-Client,X-Timestamp,X-Trans-Id,Content-Length,Last-Modified,Accept-Ranges
content-length: 5782
content-type: application/xml
etag: "61808ed864f4c3453d329071986b04ba"

To download a file without opening it in a browser, add the get parameter ?filename=some_name.ext to the link:

https://*****.selcdn.ru/container/1111_Union.patch.xml?filename=Union.patch.xml

The browser will prompt you to download the file named Union.patch.xml. The response will look as follows:

HTTP/2 200
accept-language: bytes
access-control-allow-origin: *
access-control-expose-headers: Etag,X-Client,X-Timestamp,X-Trans-Id,Last-Modified,Accept-Ranges,Content-Length,Content-Type
content-disposition: attachment; filename="1111_Union.patch.xml" <- this response adds this header, which tells the browser to download the file
content-length: 5782
content-type: application/xml
etag: "61808ed864f4c3453d329071986b04ba"

Uploading a file to a container

Request parameters

Request typeURIHeadersDescription
PUThttps://api.selcdn.ru/v1/SEL_******/container/fileX-Auth-Token — authorization token; X-Delete-At — file deletion time in Unix Timestamp format; X-Delete-After — file retention period (in seconds); Etag — Etag identifier; X-Object-Meta — metadata of the uploaded objectUploads an object to the specified container

Request example

curl -i -XPUT https://api.selcdn.ru/v1/SEL_*****/new_container/file -H "X-Auth-Token: $token" -H "X-Delete-After: 180" -T "file"

Upon successful request, a response with code 201 will be returned.

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

Deleting a file

Request parameters

Request typeURIHeadersDescription
DELETEhttps://api.selcdn.ru/v1/SEL\_******/container/fileX-Auth-Token — authorization tokenDeletes the specified file

Request example

curl -i -XDELETE https://api.selcdn.ru/v1/SEL_*****/container/file -H "X-Auth-Token: $token"

In case of success, the API returns a response with code 204.

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:

Deleting multiple objects from storage

The bulk-delete command, unlike the delete command:

  • allows you to delete several files simultaneously;
  • allows you to delete objects from different containers simultaneously;
  • works sequentially.

Only the main user token is suitable for this command.

Request parameters

Request typeURIHeadersDescription
POSThttps://api.selcdn.ru/v1/SEL_******?bulk-delete=trueX-Auth-Token — authorization token; X-Delete-After — file retention period (in seconds)Deletes several specified files simultaneously

Request example

curl -i -XPOST "https://api.selcdn.ru/v1/SEL_******?bulk-delete=true" -H "X-Auth-Token: $token" -H "Content-Type: text/plain" --data $"container/file1\ncontainer/file2\n"

Upon successful execution of the request, a response with code 200 is returned.

Response example

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-Backend-Timestamp, Etag, Last-Modified, X-Object-Manifest, X-Timestamp
Content-Type: application/json; charset=utf-8
Date: Fri, 08 Jun 2018 13:37:53 GMT
Content-Length: 101
{"Number Not Found":0,"Response Status":"200 OK","Response Body":"","Errors":null,"Number Deleted":2}

Delayed deletion using X-Delete

There are two possible header options:

  • X-Delete-At;
  • X-Delete-After.

Both options allow setting a time interval for automatic deletion of an object from storage. Headers are sent using PUT and POST requests.

X-Delete-At

The header value passed is a timestamp in Unix Epoch format. This value tells the server until what time the object should be stored. To convert to a human-readable format, it is convenient to use an online converter (.

Unix EpochHuman View
1317070737Mon Sep 26 20:58:57 2011 UTC

X-Delete-After

The header value passed is an integer number of seconds after which the object will be scheduled for deletion. Upon receiving this value, the server converts it to an X-Delete-At header and stops storing the object when that time value is reached.

Access to objects for which the X-Delete-* header was passed ceases after the time value has elapsed. The server, in response to a request for such an object, will return a 404 response. The objects themselves are automatically deleted after some time.

Double header

If both headers are passed to an object simultaneously, the system will prioritize the X-Delete-After header.

Internal operations

The current implementation has the following features:

  • if an object having X-Delete-At is placed via PUT into a container with a modified header, the object's header will be overwritten by the container's header;
  • if an object having X-Delete-At is placed via PUT with the X-Copy-From header set into a container that already has a modified header, the object's header will be preserved from the previous source and will not be overwritten;
  • when copying an object with the X-Delete-At header set using COPY and the Destination header — the header is not preserved;
  • when placing an object into a container for versioned objects via the control panel S3, the X-Delete-At / X-Delete-After header will be kept unchanged and the object will be deleted according to the specified value;
  • when placing an object into a container for versioned objects via API (COPY command with Destination header), the header is not preserved.

Managing HTTP headers for files

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

The following headers are supported:

  • Cache-Control
  • Access-Control-Allow-Origin
  • Access-Control-Max-Age
  • Access-Control-Allow-Methods
  • Access-Control-Allow-Credentials
  • Access-Control-Expose-Headers
  • Access-Control-Allow-Headers
  • Link
  • Content-Type
  • Content-Disposition (final file only)
  • Strict-Transport-Security (container only)

Request parameters

Request typeURIHeadersDescription
POSThttps://api.selcdn.ru/v1/SEL_******/containerX-Auth-Token — authorization token; X-Container-Meta-…. — header whose parameters need to be set (the header itself is specified after -Meta-, for example: X-Container-Meta-Cache-ControlSets values for the headers specified in the request

Request example

curl -i -XPOST https://api.selcdn.ru/v1/SEL_*****/container -H "X-Auth-Token: $token" \
-H "X-Container-Meta-Access-Control-Allow-Methods: HEAD, GET" \
-H "X-Container-Meta-Cache-Control: public" \
-H "X-Container-Meta-Strict-Transport-Security: max-age=31536000; includeSubDomains"

In case of success, the API returns a response with code 202.

To add the Link header to the file1 object, enter:

curl -i -XPOST https://api.selcdn.ru/v1/SEL_*****/container/file1 -H "X-Auth-Token: $token" -H "Link: rel=canonical"

To add this header to all objects in a container at once, use the following request:

curl -i -XPOST https://api.selcdn.ru/v1/SEL_*****/container -H "X-Auth-Token: $token" -H "X-Container-Meta-Link: rel=canonical"

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

Viewing headers of a specific object

To view the headers of a specific object, enter:

curl --head https://api.selcdn.ru/v1/SEL_*****/images/file.png

Support for large objects

There are no size restrictions for uploaded files in storage, but it is not recommended to place files larger than 100 MB into storage as a whole — you should use segmented uploading.

There are two options for segmented uploading: dynamic and static.

Dynamic uploading

In dynamic uploading, an object is split into segments, after which a manifest is created — an empty file containing a pointer to the container where all segments are uploaded. In the request to upload a large object, the path to the container is specified in the X-Object-Manifest header.

It is advisable to upload segments first and then create or update the manifest: the object will not be available for downloading until the upload of all segments is completed.

Example
curl -X PUT -H "X-Auth-Token: $token" https://api.selcdn.ru/v1/SEL_*****/new_container/big_object/00000001 --data-binary "1" \
curl -X PUT -H "X-Auth-Token: $token" https://api.selcdn.ru/v1/SEL_*****/new_container/big_object/00000002 --data-binary "2" \
curl -X PUT -H "X-Auth-Token: $token" https://api.selcdn.ru/v1/SEL_*****/new_container/big_object/00000003 --data-binary "3"
Manifest example
curl -X PUT -H "X-Auth-Token: $token" -H "X-Object-Manifest: new_container/big_object/" https://api.selcdn.ru/v1/SEL_*****/new_container/big_object --data-binary ""

Static uploading

During static uploading, you need to create a static manifest specifying paths to segments, their checksum (Etag), and size. The manifest is saved in a special file.

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

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

To get the manifest file, you need to execute a GET request with the query parameter ?multipart-manifest=get.

You can delete all segments and then the manifest file using a DELETE request with the query parameter ?multipart-manifest=delete.

Setting a retention period for files

Request parameters

Request typeURIHeadersDescription
PUThttps://api.selcdn.ru/v1/SEL\_******/containerX-Auth-Token — authorization token; X-Container-Meta-Default-Delete-After — retention period for all files in the container (in seconds)Sets the retention period for all files placed in the container. Upon expiry of this period, all files will be automatically deleted

Request example

curl -i -XPUT https://api.selcdn.ru/v1/SEL_*****/container -H "X-Auth-Token: $token" \
-H "X-Container-Meta-Default-Delete-After: 300"

Upon successful request, a response with code 202 will be returned.

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

Setting file metadata

Request parameters

Request typeURIHeadersDescription
POSThttps://api.selcdn.ru/v1/SEL_******/container/fileX-Auth-Token — authorization token; X-Object-Meta-Some — any additional information about the fileAdds metadata passed in the X-Object-Meta-Some header to the file

Request example

curl -i -XPOST https://api.selcdn.ru/v1/SEL_***/new_container/file -H "X-Auth-Token: $token" -H "X-Object-Meta-Some: metadata"

In case of success, the API returns a response with code 201.

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

Copying files within storage

Method 1

Request typeURIHeadersDescription
PUThttps://api.selcdn.ru/v1/SEL_******/new_location/path to container and destination folder/file nameX-Auth-Token — authorization token; X-Copy-From — path to the file to be copiedCopies a file from one location to another

During this operation, the value of the x-delete-at header is also copied, regardless of where this header was set — on the source object or the source container.

Request example
curl -i -X PUT https://api.selcdn.ru/v1/SEL_*****/container2/file -H "X-Auth-Token: $token" -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 typeURIHeadersDescription
COPYhttps://api.selcdn.ru/v1/SEL_******/container/file/path to file/X-Auth-Token — authorization token; Destination — path to the container and folder where you need to copy the fileCopies a file from one location to another

If you set the header -H "X-Fresh-Metadata: true" when using this method, the new object will be created with new headers upon copying, including without X-Delete-At.

Request example
curl -i -X COPY https://api.selcdn.ru/v1/SEL_*****/container1/file -H "X-Auth-Token: $token" -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

Setting limits

Setting limits for a container

Request parameters

Request typeURIHeadersDescription
POSThttps://api.selcdn.ru/v1/SEL_******/container/X-Auth-Token — authorization token; X-Container-Meta-Quota-Bytes — maximum storage data volume (in bytes); X-Container-Meta-Quota-Count — maximum number of files and folders in a containerSets limits for the specified container passed in the X-Container-Meta-Quota-Bytes and X-Container-Meta-Quota-Count headers

Request example

curl -i -XPOST https://api.selcdn.ru/v1/SEL_*****/container/ -H "X-Auth-Token: $token" \
-H "X-Container-Meta-Quota-Bytes: 52428800" -H "X-Container-Meta-Quota-Count: 1000"

In case of success, a response with code 202 will be returned.

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

Setting limits for an account

Request parameters

Request typeURIHeadersDescription
POSThttps://api.selcdn.ru/v1/SEL_*****/X-Auth-Token — authorization token; X-Account-Meta-Quota-Bytes — maximum storage data volume (in bytes)Sets the limit for the specified account passed in the X-Account-Meta-Quota-Bytes header

Request example

curl -i -XPOST https://api.selcdn.ru/v1/SEL_***** -H "X-Auth-Token: $token" \
-H "X-Account-Meta-Quota-Bytes: 52428800"

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