Get Object
Last Updated:2021-09-13
Interface Description
This command is used 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.
Notes:
- 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 the GetObject interface 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, refer to the PutObject interface.
- 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.
Notes: The responseContentDisposition is set in the BOS domain name. $region.bcebos.com and *.$region.bcebos.com are invalid.
Request URI
GET /v1/{bucketName}/{objectKey}
Parameter Name | Parameter Type | Required | Description | Example Value | Parameter Position |
---|---|---|---|---|---|
bucketName | String | Yes | Bucket name | "bucketName_example" | Path |
objectKey | String | Yes | Object name | "objectKey_example" | Path |
Request Header Parameters
Parameter Name | Parameter type | Required | Description | Example value |
---|---|---|---|---|
range | String | No | Specify 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 | "range_example" |
Request Body Parameters
Description of Data Structure for Request Body Field
Response Header Parameters
Parameter Name | Parameter type | Description | Example value |
---|---|---|---|
Cache-Control | String | Download the Cache setting of the Object. The common value includes private, no-cache, max-age, and must-revalidate. | |
Content-Disposition | String | Set the browser to download files. The optional values include inline, attachment; filename="download.txt". | |
Content-Length | String | The data size of the returned object. | |
Content-Range | String | If a range is available, it returns the data range of the object. | |
Content-Type | String | Object type and encoding method | |
Expires | String | Cache expiration date during the object download | |
ETag | String | HTTP protocol entity tag of the object | |
x-bce-meta-* | String | Return this item only when there is a custom meta. | |
x-bce-storage-class | String | Return STANDARD for the standard storage, STANDARD_IA for the infrequent access, COLD for the cold storage and ARCHIVE for the archive storage. If it is a multi-AZ bucket, it returns MAZ_STANDARD_IA for the multi-AZ infrequent access and MAZ_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. |
Response Body Parameters
Description of Data Structure for Response Body Field
Request Example
GET /v1/bucketName_example/objectKey_example
Common Request Header
Range: range_example
{ }
Response Example
HTTP/1.1 200 OK
<Common response header>
{ }
Error Code
Refer to the universal error code.