Downloads an object from a bucket.
Usage notes
By default, you can access the GetObject API operation over HTTP and HTTPS. To enforce access only over HTTPS, use a Bucket Policy. For more information, see Configure bucket policies to authorize other users to access OSS resources.
If an object is in the Archive storage class, you must first restore it by sending a RestoreObject request. Ensure that the request does not time out.
Permissions
By default, an Alibaba Cloud account has full permissions. RAM users or RAM roles under an Alibaba Cloud account do not have any permissions by default. The Alibaba Cloud account or account administrator must grant operation permissions through RAM policies or Bucket Policy.
|
API |
Action |
Description |
|
GetObject |
|
Downloads an object. |
|
|
When downloading an object, if you specify the object version through versionId, this permission is required. |
|
|
|
When downloading an object, if the object metadata contains X-Oss-Server-Side-Encryption: KMS, this permission is required. |
Command syntax
ossutil api get-object --bucket value --key value [flags]Parameter | Type | Description |
--accept-encoding | string | Specifies the encoding type of the client. |
--bucket | string | The name of the bucket. |
--if-match | string | If the specified ETag matches the object's ETag, OSS returns the object metadata and a |
--if-modified-since | string | If the specified time is earlier than the object's last modified time, OSS returns the object metadata and a |
--if-none-match | string | If the specified ETag does not match the object's ETag, OSS returns the object metadata and a |
--if-unmodified-since | string | If the specified time is the same as or later than the object's last modified time, OSS returns the object metadata and a |
--key | string | The full path of the object. |
--range | stringArray | The byte range of the object to retrieve. |
--response-cache-control | string | The |
--response-content-disposition | string | The |
--response-content-encoding | string | The |
--response-content-language | string | The |
--response-expires | string | The |
--version-id | string | The version ID of the object to retrieve. |
The
get-objectcommand is built on the GetObject API operation. For more information about the parameters of the API operation, see GetObject.For supported global command-line options, see Global command-line options.
Examples
Retrieve the
exampleobjectobject from theexamplebucketbucket.ossutil api get-object --bucket examplebucket --key exampleobjectRetrieve the
exampleobjectobject with the version ID123from theexamplebucketbucket.ossutil api get-object --bucket examplebucket --key exampleobject --version-id 123Retrieve a specified range of the object
exampleobjectfrom theexamplebucketbucket.ossutil api get-object --bucket examplebucket --key exampleobject --range bytes=1-10Retrieve the
exampleobjectobject from theexamplebucketbucket if the modification time ofexampleobjectis afterMon, 11 May 2020 08:16:23 GMT.ossutil api get-object --bucket examplebucket --key exampleobject --if-modified-since "Mon, 11 May 2020 08:16:23 GMT"Retrieve
exampleobjectfrom theexamplebucketbucket. The object is returned if theETagofexampleobjectis equal to123.ossutil api get-object --bucket examplebucket --key exampleobject --if-match 123Retrieve
exampleobjectfrom theexamplebucketbucket and transfer the response with Gzip compression.ossutil api get-object --bucket examplebucket --key exampleobject --accept-encoding gzip
API reference
This command is built on the GetObject RESTful API. For more customization, you can make direct API requests, which requires you to write code to calculate the signature. For more information, see GetObject.