VK Cloud logo
Updated at April 15, 2024   08:50 AM

Object

Operations with Objects:

  • Get - Download an object from a bucket
  • Upload - Upload an object to a bucket
  • Copy - Copy an object in the bucket
  • HeadObject - Get information about an object
  • Delete - Delete object
  • DeleteMultipleObjects - Delete a group of objects from the list

All operations with buckets are characterized by typical error messages, request headers and response headers. If the operation has special error messages, request or response headers, this will be indicated in the description of the operation.

Get

GET operations retrieves an object from a bucket. To use GET, you must have READ access to the object. By granting READ access to an anonymous user, you can return an object without using an authorization header.

The bucket does not have a directory hierarchy like the standard file system. However, you can create a logical hierarchy using object key names that imply a folder structure. For example, you can name the object not sample.jpg, but photos / 2020 / August / 01.jpg.

To retrieve an object with this logical hierarchy, you must specify the fully qualified name of the object in the GET operation.

Inquiry:

GET /example.txt HTTP / 1.1Host: my-test-bucket1.hb.vkcs.cloudx-amz-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855x-amz-date: 20200831T190539ZAuthorization: AWS4-HMAC-SHA256 Credential = II5JDQBAN3JYM4DNEB6C / 20170710 / ru-msk / s3 / aws4_request, SignedHeaders = host; x-amz-content-sha256; x-amz-date, Signature = e912de558677884f08b83d3bd3d558677884f07d8bd3bd3d8687884f08d4d4d1d3d1d3d2c8d8c884f04d4d4d4d1c4d4d4d4d4d4d4d4d4d4d4f4d4f4d4f4d4f4d4f8244f07104f07104f07104f07104f07104f07104f0710

Answer:

HTTP / 1.1 200 OKDate: Mon, 31 Aug 2020 19:05:39 GMTx-amz-request-id: tx00000000000000279f46e-005963d003-1268c-ru-mskaContent-Type: text / plainContent-Length: 14Accept-Ranges: bytesLast-Modified: Mon, 31 Aug 2020 19:05:09 GMTEtag: "b3a92f49e7ae64acbf6b3e76f2040f5e"Connection: closeExample text.

Upload

The PUT operation adds an object to the bucket. To perform the operation, you must have WRITE rights to the bucket.

Cloud Storage adds partial objects if the object size exceeds 50MB. If a successful response is received, then the entire object has been added to the bucket.

When performing concurrent PUT operations and when there are identical loadable objects, Cloud Storage overwrites everything except the last written object.

To prevent data corruption while traversing the network, it is recommended to use the Content-MD5 header, which checks the object against the provided MD5 value and returns an error if it does not match. Alternatively, you can compute MD5 by placing an object in a bucket and compare the returned ETag with the computed MD5.

Inquiry:

PUT /example.txt HTTP / 1.1Content-Length: 14Content-Type: text / plainHost: my-test-bucket1.hb.vkcs.cloudx-amz-content-sha256: 003f0e5fe338b17be8be93fec537764ce199ac50f4e50f2685a753c4cc781747x-amz-date: 20200831T194605Zx-amz-meta-s3cmd-attrs: uid: 1000 / gname: asb / uname: asb / gid: 1000 / mode: 33204 / mtime: 1499727909 / atime: 1499727909 / md5: fb08934ef619f205f272b0adfd6c099713 / c405time: 1499727909x-amz-storage-class: STANDARDAuthorization: AWS4-HMAC-SHA256 Credential = II5JDQBAN3JYM4DNEB6C / 20200831 / ru-msk / s3 / aws4_request, SignedHeaders = content-length; content-type; host; x-amz-content-sha256; x-amz-date; x-amz -meta-s3cmd-attrs; x-amz-storage-class, Signature = a9a9e16da23e0b37ae8362824de77d66bba2edd702ee5f291f6ecbb9ebac6013Example text.

Answer:

HTTP / 1.1 200 OKDate: Mon, 31 Aug 2020 19:46:06 GMTx-amz-request-id: tx0000000000000027bd57c-005963d97e-1268c-ru-mskaContent-Length: 0Accept-Ranges: bytesLast-Modified: Mon, 31 Aug 2020 19:05:09 GMTEtag: "fb08934ef619f205f272b0adfd6c018c"Connection: close

Copy

PUT operations can create a copy of an object that is already stored in the bucket. The copy PUT operation is identical to the sequential execution of GET and PUT. Adding the x-amz-copy-source request header causes the PUT operation to copy the source object to the target bucket.

When copying an object, you can keep most of the metadata (default) or specify new metadata. To write new metadata when copying an object, you must include the x-amz-metadata-directive: REPLACE header in the request. However, the ACL is not saved and is configured as private for the user making the request.

All copy requests must be authenticated and cannot contain message text. In addition, you must have READ access to the source object and WRITE access to the target bucket.

A copy request can return an error in two cases. This can happen when a copy request is received, or when objects are being copied. If an error occurs before the copy operation starts, a standard error will be received. If an error occurs during a copy operation, the error will be embedded in the 200 OK response. This means that a 200 OK response can contain both success and error messages.

Inquiry:

PUT /copied-example.txt HTTP / 1.1Host: my-test-bucket1.hb.vkcs.cloudx-amz-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855x-amz-copy-source: /static-images/example.txtx-amz-date: 20200831T202253Zx-amz-metadata-directive: COPYAuthorization: AWS4-HMAC-SHA256 Credential = II5JDQBAN3JYM4DNEB6C / 20170710 / ru-msk / s3 / aws4_request, SignedHeaders = host; x-amz-content-sha256; x-amz-copy-source; x-amz-date; x-amz -metadata-directive; x-amz-storage-class, Signature = 0cb03470dd80bdd41a4b8fb06c1800b27a5059b61b0303fe589578835531c877

Answer:

HTTP / 1.1 200 OKDate: Mon, 31 Aug 2020 20:22:54 GMTx-amz-request-id: tx0000000000000027d8430-005963e21d-1268c-ru-mskaContent-Length: 183Connection: close<CopyObjectResult xmlns = "http://s3.amazonaws.com/doc/2006-03-01/"><LastModified> 2020-08-31T20: 22: 54.167Z </LastModified><ETag> 7967bfe102f83fb5fc7e5a02bf05e8fc </ETag></CopyObjectResult>

HeadObject

The HEAD operation retrieves metadata from an object without returning the object itself. This operation is used only if only the object metadata is needed. In order to use the HEAD operation, you must have read rights to the object (READ).

The parameters for requesting a HEAD operation are the same as for a GET operation for an object. The response is identical to the GET response, except for the absence of a response body.

If the requested object does not exist, then the error returned depends on whether the account has additional s3: ListBucket permission.

  • If there is s3: ListBucket permission on the bucket, then an error is returned - HTTP status code 404 ("key missing").
  • If s3: ListBucket permission is not present, then an error is returned — HTTP status code 403 (“access error”).

Inquiry:

HEAD /example.txt HTTP / 1.1Host: my-test-bucket1.hb.vkcs.cloudx-amz-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855x-amz-date: 20200831T185156ZAuthorization: AWS4-HMAC-SHA256 Credential = II5JDQBAN3JYM4DNEB6C / 20170710 / ru-msk / s3 / aws4_request, SignedHeaders = host; x-amz-content-sha256; x-amz-date, Signature = e3b4998b249278fc34

Answer:

HTTP / 1.1 200 OKDate: Mon, 31 Aug 2020 18:51:58 GMTx-amz-request-id: tx0000000000000002ff1c9-00596912ce-6441-ru-mskaContent-Type: text / plainContent-Length: 14Accept-Ranges: bytesLast-Modified: Mon, 31 Aug 2020 18:40:46 GMTEtag: "b3a92f49e7ae64acbf6b3e76f2040f5e"Connection: close

Delete

DELETE operations delete the object specified in the request.

Inquiry:

DELETE /sammy.png HTTP / 1.1Host: my-test-bucket1.hb.vkcs.cloudx-amz-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855x-amz-date: 20200831T194408ZAuthorization: AWS4-HMAC-SHA256 Credential = II5JDQBAN3JYM4DNEB6C / 20170710 / ru-msk / s3 / aws4_request, SignedHeaders = host; x-amz-content-sha256; x-amz-date, Signature = c2a46b21e2e885cd, Signature = c2a46b21b504e858cfd9fdb10b8b21b2e2e85c

Answer:

HTTP / 1.1 204 No ContentDate: Mon, 31 Aug 2020 19:44:09 GMTx-amz-request-id: tx0000000000000027bbc48-005963d908-1268c-ru-mskaConnection: close

DeleteMultipleObjects

Removes objects according to the list of keys passed in the request. The list for deletion can contain no more than 1000 keys. If the object does not exist, then the response will mark it as deleted.

For this request, the Content-MD5 and Content-Length headers are required, and the list of keys for deletion is sent in XML format.

Inquiry:

DELETE /sammy.png HTTP / 1.1Host: my-test-bucket1.hb.vkcs.cloudx-amz-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855x-amz-date: 20200831T194408ZAuthorization: AWS4-HMAC-SHA256 Credential = II5JDQBAN3JYM4DNEB6C / 20170710 / ru-msk / s3 / aws4_request, SignedHeaders = host; x-amz-content-sha256; x-amz-date, Signature = c2a46b21e2e885cd, Signature = c2a46b21b504e858cfd9fdb10b8b21b2e2e85c<? xml version = "1.0" encoding = "UTF-8"?><Delete><Quiet> true </Quiet><Object><Key> Key </Key></Object>...</Delete>

Answer:

HTTP / 1.1 204 No ContentDate: Mon, 31 Aug 2020 19:44:09 GMTx-amz-request-id: tx0000000000000027bbc48-005963d908-1268c-ru-mska<DeleteResult><Deleted><Key> some / key.txt </Key></Deleted><Error><Key> some / another / key.txt </Key><Code> TextErrorCode </Code><Message> Describing message </Message></Error></DeleteResult>Connection: close