GET Object

最近更新时间:2020-02-17 15:12:59

GET Object


Description

This get operation will get the object from KS3. You need to have read access to the file. If you grant anonymous users read permission, the operation can be unsigned. If you want to generate a download link, you can refer to sending a signature through the URL querystring.

KS3's bucket does not have a directory hierarchy, similar to the desktop's file directory. However, you can achieve logical layering by giving theobject key a value with a file structure. For example, for sample.jpg, you can name itphotos/2006/February/sample.jpg.

For this get operation, you can get a logically layered object by specifying the full name of the object. For example, if you have an object named photos photos/2006/February/sample.jpg, which is placed in the bucket named examplebucket, you can think that the logical name of the resource is /examplebucket/photos/2006/February/sample.jpg.

Permissions

This interface operation requires the user to have READ permission on the Object. If the requested object does not exist, KS3 will return the corresponding information according to whether you have read permission.

  • If you have READ permission of the Bucket, KS3 will return an HTTP status code of 404 (no such key) error.
  • If you do not have READ permission of the Bucket, KS3 will return an HTTP status code of 403 (access denied) error.

Request

Syntax

GET /{ObjectKey} HTTP/1.1
Host: {BucketName}.{endpoint}
Date: {date}
Authorization: {SignatureValue}
Range:bytes=byte_range

Attention:

Request Parameters

Sometimes you may need to return a certain response header value in the GET response. For example, you may need to set the Content-Disposition value of the response header in your GET request.

You can use the query parameters listed in the following table to set the value of the response header. The set header will take effect only when KS3 returns the 200 status code. You can set returned Content-Type, Content-Language, Expires, Cache-Control, Content-Disposition and Content-Encoding through the following parameters.

Parameter Description Required
response-content-type Set response header Content-Type
Type:String
Default:None
No
response-content-language Set response header Content-Language
Type:String
Default:None
No
response-expires Set response header Expires
Type:String
Default:None
No
response-cache-control Set response header Cache-Control
Type:String
Default:None
No
response-content-disposition Set response header Content-Disposition
Type:String
Default:None
No
response-content-encoding Set response header Content-Encoding
Type:String
Default:None
No

Request Headers

This interface can use all the common request headers. In addition, it can also use the request headers listed in the following table. For more information, please click Common Request Header

Name Description Required
Range Download the object of the specified range byte. For more information about the HTTP range header, please visit http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html##sec14.35
Type:String
Default:None
Constraints: None
No
If-Modified-Since If the 'object' is changed after the specified time, the 'object' will be returned. Otherwise, 304 status code is returned.
Type:String
Default:None
Constraints: None
No
If-Unmodified-Since If the object is not changed after the specified time, the object is returned. Otherwise, 412 status code is returned.
Type:String
Default:None
Constraints: None
No
If-Match If the ETag(entity tag) of the object is the same as the specified value, the object is returned. Otherwise, 412 status code is returned.
Type:String
Default:None
Constraints: None
No
If-None-Match If the ETag(entity tag) of the object is inconsistent with the specified value, the object is returned. Otherwise, 304 status code is returned.
Type:String
Default:None
Constraints: None
No

Request Elements

The interface does not use the request elements.

Responses

Response Headers

Name Description
Content-MD5 Returns the base64 encoding of the MD5 value of the file, provided that the file is uploaded to KS3 through PUT or POST.If the file is uploaded in blocks, this response header will not be returned.
x-kss-meta-* If you use the user metadata in the PUT Object with the format of prefix x-kss-meta- suffix as your own field, the response header will return it without parsing.
Type:String
x-kss-storage-class If the file storage type is low-frequency storage, the value is STANDARD_IA. If the file storage type is archive storage, the value is ARCHIVE. If the file storage type is standard storage, the response header is not returned.
Type:String
ETag The 32-bit hexadecimal string used to identify the content of an Object. Object with different contents correspond to different ETag. For the Object created by Put Object or Post Object request, the ETag value is the MD5 value of its content. For the Object created by block upload method, the ETag value is the MD5 value of each block after string splicing. The ETag value can be used to check whether the Object content has changed.
Type: String

Response Elements

The interface does not use the response elements.

Special Errors

The interface does not return any special errors.

Examples

Sample Request

GET /my-image.jpg HTTP/1.1
Host: ks3-example.ks3-cn-beijing.ksyun.com
Date: Fri, 26 Dec 2014 06:48:45 GMT
Authorization: authorization string

Sample Response

HTTP/1.1 200 OK
x-kss-request-id: 5a868ca0ebd74bcc8eff1f1a7c9bcd6c
Date: Fri, 26 Dec 2014 06:48:46 GMT
Last-Modified: Wed, 12 Oct 2009 17:50:00 GMT
ETag: "798308f9638ea5b28d5f25e4d677ffac"
Content-Length: 434234
Content-Type: text/plain
Connection: close
Server: Tengine
Content-MD5:eYMI+WOOpbKNXyXk1nf/rA==
[434234 bytes of object data]

Attention:

  1. If the file is saved in KS3 through block upload, the Content_MD5 response header will not be returned when the GET interface is called for the file.

  2. If the file is uploaded to KS3 through the PUT or POST interface, calling the GET interface on the file will return the Content_MD5 response header.

Interface Detail Analysis

  • When setting the returned header by using parameter, it will only take effect when KS3 returns 200
  • When setting Range to download, note that the Range format cannot be wrong, otherwise KS3 will return 416
  • For the requirement of downloading private files through browser, you can refer to Sending Signature through URL QueryString

金山云,开启您的云计算之旅

注册有礼