get-object

更新时间:
复制 MD 格式

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

oss:GetObject

Downloads an object.

oss:GetObjectVersion

When downloading an object, if you specify the object version through versionId, this permission is required.

kms:Decrypt

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 200 OK status code. Otherwise, it returns a 412 Precondition Failed error.

--if-modified-since

string

If the specified time is earlier than the object's last modified time, OSS returns the object metadata and a 200 OK status code. Otherwise, it returns a 304 Not Modified status code.

--if-none-match

string

If the specified ETag does not match the object's ETag, OSS returns the object metadata and a 200 OK status code. Otherwise, it returns a 304 Not Modified status code.

--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 200 OK status code. Otherwise, it returns a 412 Precondition Failed error.

--key

string

The full path of the object.

--range

stringArray

The byte range of the object to retrieve.

--response-cache-control

string

The Cache-Control header to return in the response.

--response-content-disposition

string

The Content-Disposition header to return in the response.

--response-content-encoding

string

The Content-Encoding header to return in the response.

--response-content-language

string

The Content-Language header to return in the response.

--response-expires

string

The Expires header to return in the response.

--version-id

string

The version ID of the object to retrieve.

Note
  • The get-object command 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 exampleobject object from the examplebucket bucket.

    ossutil api get-object --bucket examplebucket --key exampleobject
  • Retrieve the exampleobject object with the version ID 123 from the examplebucket bucket.

    ossutil api get-object --bucket examplebucket --key exampleobject --version-id 123
  • Retrieve a specified range of the object exampleobject from the examplebucket bucket.

    ossutil api get-object --bucket examplebucket --key exampleobject --range bytes=1-10
  • Retrieve the exampleobject object from the examplebucket bucket if the modification time of exampleobject is after Mon, 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 exampleobject from the examplebucket bucket. The object is returned if the ETag of exampleobject is equal to 123.

    ossutil api get-object --bucket examplebucket --key exampleobject --if-match 123
  • Retrieve exampleobject from the examplebucket bucket 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.