All Products
Search
Document Center

Object Storage Service:get-object

Last Updated:Feb 27, 2025

Queries an object in a bucket.

Usage notes

  • By default, the GetObject operation supports access over HTTP and HTTPS. To allow access to a bucket only over HTTPS, configure a bucket policy to specify the access method. For more information, see Configure bucket policies to authorize other users to access OSS resources.

  • If the storage class of the object that you want to query is Archive, you must send a RestoreObject request to restore the object before you call the GetObject operation. Make sure that the request does not time out.

Permissions Description

By default, an Alibaba Cloud account has full permissions. RAM users or RAM roles under an Alibaba Cloud account initially have no permissions. The Alibaba Cloud account or an administrator must assign operation permissions through RAM Policy or Bucket Policy.

API

Action

Description

GetObject

oss:GetObject

Grants the permission to download an object.

oss:GetObjectVersion

Grants the permission to query object versions. This permission is required if you want to download a specific version of an object.

kms:Decrypt

Grants the permission to use Key Management Service (KMS) decryption. This permission is required if you want to download an object in parts that you encrypt by specifying the x-oss-server-side-encryption header.

Command syntax

ossutil api get-object --bucket value --key value [flags]

Parameter

Type

Description

--accept-encoding

string

The encoding method at the client side.

--bucket

string

The name of the bucket.

--if-match

string

If the ETag specified in the request matches the ETag of the object, the object metadata and 200 OK are returned. Otherwise, 412 Precondition Failed is returned.

--if-modified-since

string

If the specified time is earlier than the last modified time of the object, the object metadata and 200 OK are returned. Otherwise, 304 Not Modified is returned.

--if-none-match

string

If the input ETag does not match the ETag of the object, the object metadata and 200 OK are returned. Otherwise, 304 Not Modified is returned.

--if-unmodified-since

string

If the specified time is equal to or later than the last modified time of the object, the object metadata and 200 OK are returned. Otherwise, 412 Precondition Failed is returned.

--key

string

The full path of the object.

--range

stringArray

The range of data that you want to query.

--response-cache-control

string

The Cache-control header to be returned in the response.

--response-content-disposition

string

The Content-disposition header to be returned in the response.

--response-content-encoding

string

The Content-encoding header to be returned in the response.

--response-content-language

string

The Content-language header to be returned in the response.

--response-expires

string

The Expires header to be returned in the response.

--version-id

string

The version ID of the object to be restored.

Note
  • The get-object command corresponds to the GetObject operation. For more information about the parameters in the GetObject operation, see GetObject.

  • For more information about supported global command-line options, see Global command-line options.

Examples

  • Query the exampleobject object in the examplebucket bucket.

    ossutil api get-object --bucket examplebucket --key exampleobject
  • Query the exampleobject object whose version ID is 123 in the examplebucket bucket.

    ossutil api get-object --bucket examplebucket --key exampleobject --version-id 123
  • Query a specific range of data (byte 1 to byte 10) of the exampleobject object in the examplebucket bucket.

    ossutil api get-object --bucket examplebucket --key exampleobject --range bytes=1-10
  • Query the exampleobject object in the examplebucket bucket. If the last modified time of the exampleobject object is earlier than Mon, 11 May 2020 08:16:23 GMT, the object is returned.

    ossutil api get-object --bucket examplebucket --key exampleobject --if-modified-since "Mon, 11 May 2020 08:16:23 GMT"
  • Query the exampleobject object in the examplebucket bucket. If the ETag of the exampleobject object is 123, the object is returned.

    ossutil api get-object --bucket examplebucket --key exampleobject --if-match 123
  • Query the exampleobject object in the examplebucket bucket and return the object in the GZIP format.

    ossutil api get-object --bucket examplebucket --key exampleobject --accept-encoding gzip

Related API operation

The methods described above are fundamentally implemented based on the RESTful API, which you can directly call if your business requires a high level of customization. To directly call an API, you must include the signature calculation in your code. For more information, see GetObject.