All Products
Search
Document Center

Object Storage Service:put-object

Last Updated:Jun 04, 2026

Uploads an object to a bucket.

Usage notes

  • The object to upload cannot be larger than 5 GB.

  • By default, if a same-name object exists and you have access permissions, the new object overwrites it.

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

PutObject

oss:PutObject

Uploads an object.

oss:PutObjectTagging

Required if you specify object tags by using the x-oss-tagging header when you upload an object.

kms:GenerateDataKey

Required if the X-Oss-Server-Side-Encryption: KMS header is set to KMS when you upload an object.

kms:Decrypt

Command syntax

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

Parameter

Type

Description

--body

string

The request body.

--bucket

string

The name of the bucket.

--cache-control

string

The caching behavior of the object.

--content-disposition

string

The download filename of the object.

--content-encoding

string

The encoding format of the object content.

--expires

string

The expiration time.

--forbid-overwrite

boolean

Whether to forbid overwriting a same-name object.

--key

string

The full path of the object.

--metadata

stringArray

The object metadata. Use x-oss-meta-* prefixed parameters for custom metadata.

--object-acl

string

The access control list (ACL) for the object.

--server-side-data-encryption

string

The server-side encryption algorithm for the object.

--server-side-encryption

string

The server-side encryption method.

--server-side-encryption-key-id

string

The ID of the customer master key (CMK) managed by KMS.

--storage-class

string

The storage class of the object.

--tagging

string

The object tags. Specify multiple tags in the format TagA=A&TagB=B.

Note
  • The put-object command maps to the PutObject API operation. For more information about the parameters in the PutObject operation, see PutObject.

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

Examples

  • Upload an object from a string.

    ossutil api put-object --bucket examplebucket --key exampleobject --body "hi oss"
  • Upload an object from a local file.

    ossutil api put-object --bucket examplebucket --key exampleobject --body file://uploadFile
  • Upload a string with custom metadata.

    ossutil api put-object --bucket examplebucket --key exampleobject  --metadata user=aliyun --metadata email=ali***@aliyuncs.com --body "hi oss"
  • Upload a string with tags.

    ossutil api put-object --bucket examplebucket --key exampleobject --body "hi oss" --tagging "TagA=A&TagB=B"
  • Upload a string with a specified ACL and storage class.

    ossutil api put-object --bucket examplebucket --key exampleobject --body "hi oss" --object-acl private --storage-class IA
  • Upload a string with server-side encryption.

    ossutil api put-object --bucket examplebucket --key exampleobject --body "hi oss" --server-side-encryption KMS --server-side-data-encryption SM4 --server-side-encryption-key-id 9468da86-3509-4f8d-a61e-6eab1eac****
  • Upload a string without overwriting a same-name object.

    ossutil api put-object --bucket examplebucket --key exampleobject --body "hi oss" --forbid-overwrite true
  • Upload a string with cache control settings.

    ossutil api put-object --bucket examplebucket --key exampleobject --body "hi oss" --cache-control no-cache
  • Upload a string with a custom download filename.

    ossutil api put-object --bucket examplebucket --key exampleobject --body "hi oss" --content-disposition "attachment;filename=oss_download.jpg"