GetObject
Interface Description
This command allows you to get an object from BOS. This operation requires the requester to have the read permission of this object. The requester can set the range in the header to specify the range of the object data.
Request
-
Request syntax
GET /<ObjectKey> HTTP/1.1 Host: <BucketName>.bj.bcebos.com Date: <Date> Authorization: <AuthorizationString> Range: <Range_String>
-
Request header field
Name Type Description Required? Range String It specifies the file range returned by the object. Setting bytes=0-9 means that the characters 0-9 are transmitted. All data is returned by default. No -
Request parameters
None
Response
-
Response header field
Name Type Description Cache-Control String Cache setting for downloading the object. The common optional values are private
,no-cache
,max-age
, andmust-revalidate
.Content-Disposition String Set the browser to download files. The optional values are inline
andattachment
. Filename="download.txt".Content-Length Long Int It returns the data size of the object. Content-Range String If a range is available, it returns the data range of the object. Content-Type String Object type and coding method. Expires String Cache expiration date during the object download. ETag String HTTP protocol entity tag of the object. x-bce-meta-* String It returns this item only when there is a custom meta. x-bce-storage-class String It returns STANDARD
for the standard storage,STANDARD_IA
for the infrequent access,COLD
for the cold storage andARCHIVE
for the archive storage. If it is a multi-AZ bucket, it returnsMAZ_STANDARD_IA
for the multi-AZ infrequent access andMAZ_STANDARD
for the multi-AZ standard storage.x-bce-server-side-encryption String Server encryption type of the object. Only AES256 encryption is supported currently. Considerations
- GetObject supports the resumeable upload through the range parameter. It is recommended to enable this feature for the large object.
- If the range parameter is used in the request header, the return message contains the entire file length and current return range. For example: Content-Range: bytes 0-9/44, which indicates that the entire file length is 44 and the current return range is 0-9.
- For an object with a range size of 0 byte, it returns “Error 400”. The range is a left and right closed interval.
- The archive storage object needs to be restored before GetObject API is called.
If you want to get some specific header information in the response request, you can implement it in the following two ways:
-
If you add the header information during PutObject, the system directly returns the information in the response during GetObject. For details, see PutObject API.
Note: The responseContentDisposition is set in the BOS domain name. $region.bcebos.com and *.$region.bcebos.com are invalid.
-
If you add “responseXXX=YYY” directly in queryString during GetObject, the returned header contains “XXX: YYY”. YYY”. For example, GET /testBucket/testObject?responseContentType= image/jpg, the response of this HTTP request contains “Content-Type: image/jpg”. image/jpg”。
The specific form is response$header=urlencode (value). Note that $header only supports “ContentDisposition, ContentType, ContentLanguage, Expires, CacheControl and ContentEncoding” currently.
-
Response element
None
Example
-
Request example
GET /ObjectName Host: BucketName.bj.bcebos.com Date: Wed, 06 Apr 2016 06:34:40 GMT Authorization: AuthorizationString Range: bytes=0-9
-
Response example
HTTP/1.1 206 Partial Content x-bce-request-id: 4db2b34d-654d-4d8a-b49b-3049ca786409 x-bce-storage-class: STANDARD Date: Wed, 06 Apr 2016 06:34:40 GMT Last-Modified: Fri, 28 Jan 2011 20:10:32 GMT ETag: "b2419b1e3fd45d596ee22bdf62aaaa2f" Accept-Ranges: bytes Content-Range: bytes 0-9/443 Content-Type: text/plain Content-Length: 10 Server: BceBos [10 bytes of object data]