Skip to main content

Swift API (old)

warning

URLs and methods of this Swift API version will be supported until October 5, 2027. On October 5, 2027 at 11:00 (UTC+3), they will be disabled. Some features will no longer be supported.

We recommend using the S3 API, for details, see the Configure S3 after update instructions.

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 authentication, the storage is accessed via a URL like: https://api.selcdn.ru/v1/SEL_*****, where ***** is the user account number. The URL also specifies the API version (v1).

https://api.selcdn.ru/v1/SEL_*****/container_name is typically used for authorized client operations. For example, when working with private containers, deleting/adding objects, or managing metadata. This is the URL format in the OpenStack Object API. For more information, see the OpenStack documentation.

The ******.selcdn.ru domain is a personal numbered account domain that can be found using the command in the X-Storage-Url header:

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.

The personal account domain can also be found in the control panel in container settings under 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 deprecate numbered domains, so it is recommended to use links such as 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 how to authenticate and obtain a token for working with the API. The pool is 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 storage access password 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_******/container

X-Auth-Token — authentication 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

Sample request

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"

If the request is successful, a response with code 201 will be returned.

Sample response

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 — authentication tokenReturns information about the specified container

Response parameters

ParameterValue
X-Container-Object-Countnumber of objects in the container
X-Container-Bytes-Usedtotal size 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 amount of data downloaded from the container, bytes
X-Received-Bytestotal amount of data uploaded to the container, bytes

Sample request

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

If the request is successful, the API returns a response with code 204.

Sample response

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, modifying, and deleting container metadata

Request parameters

Request typeURIHeadersDescription
POSThttps://api.selcdn.ru/v1/SEL_*****/containerX-Auth-Token — authentication token; X-Container-Meta-Type; X-Container-Meta-Some — container metadataSets the metadata passed in the X-Container-Meta-Some header for the specified container
POSThttps://api.selcdn.ru/v1/SEL_*****/containerX-Auth-Token — authentication 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 — authentication token; X-Remove-Container-Meta-Some — container metadata to be deletedDeletes metadata passed in the X-Remove-Container-Meta-Some header

Sample request

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 — authentication tokenReturns a list of files in the specified container. The list of objects is limited to 10000. Use the marker and limit query parameters for flexible retrieval of container object lists

Sample request

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

Sample response

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

You can also use additional query parameters in the request to get a list of files, 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 in json format will be returned. You can also specify another format for displaying the list — xml:

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

Using the limit parameter, you can specify the exact number of files to be included in the list. This feature is useful when working with containers storing multiple 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. There will be no information about any other files in the list.

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

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

As a result of 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 whose names start with the specified combination of letters in the list:

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 certain 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 preceding the dot will be displayed (only names without extension).

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 — authentication tokenDeletes the specified container

Sample request

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

If the request is successful, the API returns a response with code 204.

Sample response

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 — authentication token (required only when downloading from a private container; files can be downloaded from public containers 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

Sample request

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

To open the 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 offer 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 header is added to the response and 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 typeURIHeadersPOST
PUThttps://api.selcdn.ru/v1/SEL_*****/container/fileX-Auth-Token — authentication 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

Sample request

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

If the request is successful, a response with code 201 will be returned.

Sample response

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 — authentication tokenDeletes the specified file

Sample request

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

If the request is successful, the API returns a response with code 204.

Sample response

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 deleting multiple files simultaneously;
  • allows deleting objects from different containers simultaneously;
  • runs sequentially.

Only the primary user token is suitable for this command.

Request parameters

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

Sample request

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"

If the request is successful, a response with code 200 is returned.

Sample response

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}

Deferred deletion using X-Delete

There are two possible header options:

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

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

X-Delete-At

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

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

X-Delete-After

An integer number of seconds is passed as the header value, after which the object will be scheduled for deletion. The server, upon receiving this value, converts it into the X-Delete-At header and stops storing the object when the specified time value occurs.

Access to objects that were passed the X-Delete-* header is terminated after the time value has expired. The server will return a 404 response in reply to a request for such an object. The objects themselves are automatically deleted after some time.

Dual header

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

Internal operations

The current implementation has the following features:

  • if an object with X-Delete-At is placed using PUT into a container with a modified header, the object header will be overwritten with the container header;
  • if an object with X-Delete-At is placed using PUT with the X-Copy-From header set into a container that already has a modified header, the object 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 S3 control panel, the X-Delete-At / X-Delete-After header will be preserved unchanged and the object will be deleted according to the specified value;
  • when placing an object into a container for versioned objects using the API (COPY command with the 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 to manage caching on the client side (and on intermediate proxy servers), as well as to process 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 (destination file only)
  • Strict-Transport-Security (container only)

Request parameters

Request typeURIHeadersDescription
POSThttps://api.selcdn.ru/v1/SEL_*****/containerX-Auth-Token — authentication 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 headers specified in the request

Sample request

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"

If the request is successful, 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 the container at once, the following request is used:

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

Sample response

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 headers of a specific object, enter:

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

Support for large objects

Storage has no limits on the size of uploaded files, but uploading files larger than 100 MB in their entirety is not recommended — segmented upload should be used.

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

Dynamic upload

In dynamic upload, the object is split into segments, after which a manifest is created — an empty file containing a pointer to the container into which 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 preferable to upload segments first and then create or update the manifest: the object will not be available for download 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"
Sample manifest
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 upload

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

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

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

To retrieve 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 retention period for files

Request parameters

Request typeURIHeadersDescription
PUThttps://api.selcdn.ru/v1/SEL\_****\*/containerX-Auth-Token — authentication 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 expiration of this period, all files will be automatically deleted

Sample request

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

If the request is successful, a response with code 202 will be returned.

Sample response

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 — authentication token; X-Object-Meta-Some — any additional information about the fileAdds metadata passed in the X-Object-Meta-Some header to the file

Sample request

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

If the request is successful, the API returns a response with code 201.

Sample response

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 destination container and folder/file nameX-Auth-Token — authentication token; X-Copy-From — path to the file to be copiedCopies a file from one location to another

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

Sample request
curl -i -X PUT https://api.selcdn.ru/v1/SEL_*****/container2/file -H "X-Auth-Token: $token" -H "X-Copy-From: /container1/file"
Sample response
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 — authentication token; Destination — path to the container and folder where the file should be copiedCopies a file from one location to another

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

Sample request
curl -i -X COPY https://api.selcdn.ru/v1/SEL_*****/container1/file -H "X-Auth-Token: $token" -H "Destination: /container2/file"
Sample response
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 — authentication token; X-Container-Meta-Quota-Bytes — maximum allowed size of stored data (in bytes); X-Container-Meta-Quota-Count — maximum possible number of files and folders in the containerSets limits passed in the X-Container-Meta-Quota-Bytes and X-Container-Meta-Quota-Count headers for the specified container

Sample request

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"

If the request is successful, a response with code 202 will be returned.

Sample response

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 — authentication token; X-Account-Meta-Quota-Bytes — maximum allowed size of stored data (in bytes)Sets the limit passed in the X-Account-Meta-Quota-Bytes header for the specified account

Sample request

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

Sample response

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