PutObject
Last Updated:2021-12-08
Interface Description
This interface is used to upload a file to the specified bucket. The requester must have the write permission. Before PutObject, you need to ensure that the corresponding bucket already exists. The length range of object files supported by BOS is 0-5 GB. If you need to upload files larger than 5 GB, see MultiPartUpload Guide.
Request
PUT /<ObjectName> HTTP/1.1
Host: <BucketName>.bj.bcebos.com
Date: <Date>
Authorization: <AuthorizationString>
Content-Type: text/plain
Content-Length: <Content_Length>
x-bce-storage-class: <Storage_class>
-
Request parameters
No special parameters.
-
Request header field
Name Type Description Required? Cache-Control String Cache setting for downloading the object. The common optional values are private
,no-cache
,max-age
andmust-revalidate
No Content-Disposition String Set the browser to download files. The optional values are inline
andattachment
. Filename="download.txt".No Content-MD5 String The MD5 digest of the HTTP request content defined in RFC2616 can be contained to verify whether the file saved in BOS is consistent with the user expected file. No Expires String It is used to set the cache expiration date during the object download. If the time is not set, BOS sets the cache expiration date to three days by default. No x-bce-meta-* String User-defined meta No x-bce-content-sha256 String It verifies whether the file saved in BOS is consistent with the user expected file through this field, and the verification accuracy of Sha256 is higher. The Sha256 value of the data transmitted must match it. Otherwise, PutObject fails. No x-bce-content-crc32 String It uploads the CRC (cyclic redundancy check) value of the object. No x-bce-storage-class String It specifies the storage type of the object. STANDARD_IA
represents the infrequent access,COLD
represents the cold storage, andARCHIVE
represents the archive storage. If it is not specified, it is theSTANDARD
by default. If it is a Multi-AZ bucket,MAZ_STANDARD_IA
represents the Multi-AZ infrequent access. If it is not specified, it is aMAZ_STANDARD
storage by default and cannot be other values.No x-bce-acl String Header supported by CannedACL, in which the user sets the permission of the object, whose value is private or public-read. No x-bce-grant-read String Header supported by CannedACL, in which the user sets the read permission of the object. It supports multiple IDs, separated by commas No x-bce-grant-full-control String Header supported by CannedACL, in which the user sets the FULL_CONTROL permission of the object. It supports multiple IDs, separated by commas No x-bce-server-side-encryption String Server encryption algorithm, only AES256 is supported currently. No
Response
Considerations
- Content-Length is a required parameter. If Content-Length specified by the requester is shorter than the actual request body (actual data of object), BOS only saves the data with the length specified by Content-Length, and the excessive data is discarded directly. In contrast, if Content-Length is long, BOS waits for the requester to upload the data until it is timeout.
- At present, BOS does not support the version. If the requester repeatedly puts an object, the data uploaded previously is overwritten.
Example
PUT /ObjectName HTTP/1.1
Host: BucketName.bj.bcebos.com
Date: Wed, 06 Apr 2016 06:34:40 GMT
Authorization: AuthorizationString
Content-Type: text/plain
Content-Length: 11434
x-bce-storage-class: STANDARD_IA
[11434 bytes of object data]
HTTP/1.1 200 OK
x-bce-request-id: 4db2b34d-654d-4d8a-b49b-3049ca786409
Date: Wed, 06 Apr 2016 06:34:40 GMT
ETag: "1b2cf535f27731c974343645a3985328"
Content-Length: 0
Connection: close
Server: BceBos