Skip to main content

Swift (old)

For your information

This is the old version of the Swift API that was used before the object store upgrade. URLs and methods of the old version of Swift API are still supported, but will be disabled in the future. We recommend using the new version of Swift API.

The Swift API is intended for applications that work with user files placed in the storage or send their own data to the storage. Interaction with the Swift API is performed using standard HTTP requests. The documentation describes the currently available API calls, request and response formats. Currently, the following operations can be performed using the Swift API:

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

URL format

Host for all API requests — https://api.selcdn.ru

After authorization, access to the storage is provided by URL of the following form: 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 the work of an authorized client. For example, when working with private containers or when deleting/adding objects, and when working with metadata. This is the URL format in the Openstack Object API. More details in Openstack documentation.

The domain * *****.selcdn.ru is the personal number domain of the account, which can be recognized by 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 made for this domain when you use your domains that are bound to the container, and the data that is 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 out the personal domain of the account in the control panel in the 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 abandon numbered domains, so it is recommended to use links like https://api.selcdn.ru/v1/SEL_ *****..

API access

In order to successfully fulfill requests to the API, you need to:

  • be a registered Selectel user;
  • to have a sufficient amount on the balance sheet;
  • have a login and password to access the storage;
  • get a unique access key (token) that will be passed in all requests.

Authorization and token receipt

This section describes how to authorize and get a token to work with API. Pool — ru-1, for software that requires specifying a pool (note --storage-openstack-region).

When using all three methods, pay attention to the following points:

  • the token is valid for 24 hours;
  • after 24 hours since the last token receipt, the API will return responses with the code 401, in which case the token will have to be received again;
  • if you request a token 12 hours after the last authorization, the token will be updated and the token received earlier will become invalid.

Authorization by protocol v1

Example request

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

If the request is successful, a response with code 204 (No Content) will be returned.

Example answer

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 typeURIHeadingsDescription
GEThttps://api.selcdn.ru/auth/v1.0X-Auth-User — account number; X-Auth-Key — password for accessing the repositoryReturns the authorization key (token) for working with the storage via API, which should be passed in all subsequent requests

The password to access the storage is specified in the control panel.

Response Parameters

ParameterSignificance
X-Expire-Auth-Tokenauthorization key validity period (in seconds)
X-Storage-URLURL to access the storage
X-Auth-Tokenauthorization key
X-Storage-Tokenauthorization key (the same as the previous parameter)

Protocol v2 authorization

Example request

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

Example answer

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 by v3 protocol

Example request

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

Example answer

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 transactions

Getting account information

Example request

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

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

Example answer

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

ParameterSignificance
X-Account-Bytes-Used.total amount of stored data, bytes
X-Account-Container-Countnumber of containers
X-Account-Object-Counttotal number of stored objects

Getting information about the storage

Request type: GET

Request parameters

ParameterSignificance
X-Auth-Tokenauthorization key

Example request

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

Example answer

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

ParameterSignificance
X-Account-Bytes-Used.total amount of stored data, bytes
X-Account-Container-Countnumber of containers
X-Account-Object-Counttotal number of stored objects

Container operations

Getting the list of containers

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

Example request

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

Example answer

container1
container2
container3
сontainer4

Example request

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

Example answer

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

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

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

Creating a new container

Request parameters

Request typeURIHeadingsDescription
PUThttps://api.selcdn.ru/v1/SEL_*******/container.X-Auth-Token — authorization token; X-Container-Meta-Type — container type: public or 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

Example 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.

Example answer

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

Obtaining container information

Request parameters

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

Response Parameters

ParameterSignificance
X-Container-Object-Countnumber of objects in the container
X-Container-Bytes-Used.total size of all stored objects in bytes
X-Container-Meta-TypeContainer type (public or private)
X-Container-Meta-Somecontainer metadata
X-Container-Domainscontainer bound domains
X-Transfered-Bytestotal amount of information downloaded from the container, bytes
X-Received-Bytestotal amount of information loaded into the container, bytes

Example request

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

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

Example answer

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

Set, modify, and delete container metadata

Request parameters

Request typeURIHeadingsDescription
POSThttps://api.selcdn.ru/v1/SEL_*******/container.X-Auth-Token — authorization 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_*******/container.X-Auth-Token — authorization token; X-Container-Meta-Some — container metadataReplaces the metadata with the new metadata that is passed in the X-Container-Meta-Some header
POSThttps://api.selcdn.ru/v1/SEL_*******/container.X-Auth-Token — authorization token; X-Remove-Container-Meta-Some — container metadata to be removedRemoves metadata passed in the X-Remove-Container-Meta-Some header

Example request

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

Getting the list of files in the container

Request parameters

Request typeURIHeadingsDescription
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 10000. Use the query parameters marker and limit to flexibly get lists of objects in the container

Example request

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

Example answer

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 a file list request, such as:

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

This command will return a list of files in json format.You can also specify another format for outputting the list — xml:

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

The limit parameter allows you to specify the exact number of files to be included in the list. This feature 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 this command only the first 20 files will be included in the list. There will be no information about all 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 query, the list will show the files that come after the file named file3.The previous files, as well as file3 itself, will not be included in the list.

With the prefix parameter, you can include files whose names begin with the specified letter combination in the list:

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

With the delimiter parameter, you can output only the part of the filename that comes before a certain character, for example:

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

This command will output only the part of the file names that goes before the dot (only names without extension).

Removing a container

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

Request parameters

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

Example 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.

Example answer

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

File handling

Downloading a file from a container

Request parameters

Request typeURIHeadingsDescription
GEThttps://api.selcdn.ru/v1/SEL_*******/container/fileX-Auth-Token — authorization token (mandatory 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-Since.Downloads the specified file

Example request

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

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

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

The answer would be 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 parameter ?filename=some_name.ext to the get link:

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

The browser will prompt you to download a 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" ← в ответе добавляется этот заголовок, который говорит браузеру скачать файл
content-length: 5782
content-type: application/xml
etag: "61808ed864f4c3453d329071986b04ba"

Uploading a file to a container

Request parameters

Request typeURIHeadingsDescription
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 time (in seconds); Etag — Etag identifier; X-Object-Meta — metadata of the object to be loadedLoads the object into the specified container

Example 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.

Example answer

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 typeURIHeadingsDescription
DELETEhttps://api.selcdn.ru/v1/SEL\_******\*/container/fileX-Auth-Token — authorization tokenDeletes the specified file

Example 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.

Example answer

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 is unlike the delete command:

  • allows you to delete multiple files at the same time;
  • allows you to delete objects from different containers at the same time;
  • works in sequence.

Only the primary user's token is suitable for this command to work.

Request parameters

Request typeURIHeadingsDescription
POSThttps://api.selcdn.ru/v1/SEL_*********? bulk-delete=true.X-Auth-Token — authorization token; X-Delete-After — file retention period (in seconds)Deletes multiple specified files at the same time

Example 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.

Example answer

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 with 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

The header value is a timestamp value in Unix Epoch format. This value will tell the server what time the object should be stored until. It is convenient to use an online converter to convert to human-readable form.

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

X-Delete-After

The header value is an integer number of seconds after which the object will be sent for deletion. The server, having received this value, converts it into the X-Delete-At header and stops storing the object when the specified time value is reached.

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

Double header

If an object is passed both headers at the same time, the system will prioritize the X-Delete-After header.

Internal operations

The current implementation has the following features:

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

Managing HTTP headers for files

HTTP headers can be set for all files placed in the repository.Headers are used to manage client-side caching (and intermediate proxy servers), and to handle cross-domain requests (CORS).

The following headings 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 (for destination file only)
  • Strict-Transport-Security (container only)

Request parameters

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

Example 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 a 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, a query is used:

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

Example answer

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 the headers of a specific object

To view the headings of a specific object, type:

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

Support for large objects

There is no limit on the size of uploaded files in the repository, but files larger than 100 MB are not recommended to be placed in the repository as a whole — you should use segmented uploading.

There are two variants of segmented bootstrapping: dynamic and statistical.

Dynamic loading

In dynamic loading, the object is broken into segments and then a manifest is created, an empty file containing a pointer to the container in which all segments are loaded.In a request to load a large object, the path to the container is specified in the X-Object-Manifest header.

It is preferable to download segments first before creating or updating the manifest: the object will not be available for download until all segments have finished downloading.

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"
Example manifesto
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 loading

When static booting, you need to create a static manifest with the paths to the segments, their checksum (Etag) and size. The manifest is saved in a special file.

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

The manifest file should be loaded into the repositoryPUT request with the query-parameter ?multipart-manifest=ruth with the header X-Static-Large-Object: True.

To get the manifest file, you need to make 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 the retention period for files

Request parameters

Request typeURIHeadingsDescription
PUThttps://api.selcdn.ru/v1/SEL\_******\*/container.X-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. After this period expires, all files will be automatically deleted

Example 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.

Example answer

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 typeURIHeadingsDescription
POSThttps://api.selcdn.ru/v1/SEL_*******/container/fileX-Auth-Token — authorization token; X-Object-Meta-Some — any additional information about the fileAdds the metadata passed in the X-Object-Meta-Some header to the file

Example 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.

Example answer

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 the storage

Method 1

Request typeURIHeadingsDescription
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 location

This operation also copies the value of the x-delete-at header, regardless of whether the header was set to the source object or the source container.

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

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

Example request
curl -i -X COPY https://api.selcdn.ru/v1/SEL_*****/container1/file -H "X-Auth-Token: $token" -H "Destination: /container2/file"
Example answer
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 the container

Request parameters

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

Example 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.

Example answer

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 account limits

Request parameters

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

Example request

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

Example answer

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