百度智能云

All Product Document

          Object Storage

          UploadPartCopy

          Interface Description

          After InitiateMultipartUpload is called to get UploadId, we need to copy the data (part) after the object splitting by executing the UploadPartCopy command. To identify the relative position of each part in the object, you need to specify a partNumber parameter in UploadPartCopy. The value range of partNumber is 1-10,000, i.e., each three-step copy can copy 10,000 parts at most and 1 part at least.

          Descriptions:

          • For each copy part, you can copy up to 5 GB of data.
          • The meta information of the destination object got by the three-step copy is not copied from the source object. The meta information needs to be uploaded by the user during CompleteMultipartUpload or updated by the CopyObject API copying itself after CompleteMultipartUpload.
          • Different parts may come from different objects during UploadPartCopy, which is not limited by the system.
          • At present, the cross-region file copy is supported, i.e., the source bucket and destination bucket of the copied file cannot be in the same region. At present, you can copy the data from other regions to this region only. The cross-region data flow is charged for the data flow generated by the copy during cross-region file copy. For the cross-region charging standards, see Product Pricing.
          • The three-step copy is not applicable for the Append Object. Append Object can use the common copy method to complete the backup and meta update.
          • If the copied source object is of archive storage type, it is necessary to first call the RestoreObject API to restore the archive storage object.

          Request

          • Request syntax

            PUT /<ObjectName>?uploadId=UploadId&partNumber=PartNumber HTTP/1.1
            Host: <BucketName>.bj.bcebos.com
            Date: <Date>
            Authorization: <AuthorizationString>
            Content-Type: text/plain
            Content-Length: <ContentLength>
            x-bce-copy-source: /SrcBucket/SrcObject
            x-bce-copy-source-range: bytes=0-9
          • Request header field

            header Required? Description
            x-bce-copy-source Yes Copy the source file, such as /SrcBucket/SrcObject.
            x-bce-copy-source-range No The byte range of the copy source file must be in the format of bytes=first-last. For example, bytes=0-9 represents the copy of the first 10 bytes. If this header is not provided, the entire file is copied. Except for the last part, other parts need to be greater than or equal to 5 MB, or be an integral multiple of 1 MB. A single part cannot exceed 5 GB, and the size of the whole object cannot exceed 5 TB.
            x-bce-copy-source-if-match No If the eTag value of the source file is the same as that provided by this header, it is copied. Otherwise, it is not copied.
            x-bce-copy-source-if-none-match No If the eTag value of the source file is different from that provided by this header, it is copied. Otherwise, it is not copied.
            x-bce-copy-source-if-unmodifed-since No If the source file is not subject to modification after the time specified by this header, it is copied. Otherwise, it is not copied.
            x-bce-copy-source-if-modifed-since No If the source file is subject to modification after the time specified by this header, it is copied. Otherwise, it is not copied.

            Descriptions:

            The format of each field is the same as the corresponding field of CopyObject API. Assume that the object content is "0123456789," and the length is 10. An example of x-bce-copy-source-rang is as follows:

            • range: 0-3, copy "0123".
            • range: 4-, copy the number starting from the subscript of 4 to the end of the file, i.e., "456789".
            • range: -4, copy the last 4 numbers, i.e., "6789".
          • Request parameters

            Name Type Parameter Position Description Required?
            partNumber Int Query Parameters Serial number of this part in the destination object. The value range of partNum is 1-10000. The PartNumber of a MultiPart must be strictly sorted. For example, there are three parts, and the PartNumber can be 1, 3, and 5. Yes
            uploadId String Query Parameter UploadId got by InitiateMultipartUpload Yes

          Response

          • Response element

            Name Description
            ETag Copy the ETag of the destination object.
            lastModified The modification time of the destination object

            Considerations

            1. UploadPartCopy returns the eTag of this part. This eTag is required in the third step of MultipartUpload. It is also recommended that users verify the correctness of the data uploaded through eTag.
            2. To maintain the HTTP connection during the copy, the HTTP results of UploadPartCopy API may use the Transfer-Encoded: Chunked Encoding. Chunked coding.
            3. If the server error occurs during UploadPartCopy, the HTTP status code may return 2XX, but the copy fails. Judge the copy results according to JSON in the HTTP body.

          Example

          • Request example

            PUT /ObjectName?uploadId=a44cc9bab11cbd156984767aad637851&partNumber=1 HTTP/1.1
            Host: BucketName.bj.bcebos.com
            Date: <Date>
            Authorization: <AuthorizationString>
            Content-Type: text/plain
            Content-Length: 0
            x-bce-copy-source: /SrcBucket/SrcObject
            x-bce-copy-source-range: bytes=0-9
          • Response example

            HTTP/1.1 200 OK
            Date: Thu, 12 May 2016 09:14:32 GMT
            Content-Type: application/json; charset=utf-8
            Connection: keep-alive
            Server: BceBos
            x-bce-debug-id: MTAuNjMuMTIzLjI3OlRodSwgMTIgTWF5IDIwMTYgMTc6MTQ6MzIgQ1NUOjg3MjkzODMwMA==
            x-bce-request-id: bb90cc9c-2b80-462c-87a4-095e610c9a2f
            Transfer-Encoding: chunked
            {   
                "lastModified":"2016-05-12T09:14:32Z",
                "eTag":"67b92a7c2a9b9c1809a6ae3295dcc127"
            }

            You need to judge the copy failure according to the returned JSON.

            HTTP/1.1 200 OK
            Date: Thu, 12 May 2016 09:14:32 GMT
            Content-Type: application/json; charset=utf-8
            Connection: keep-alive
            Server: BceBos
            x-bce-debug-id: MTAuNjMuMTIzLjI3OlRodSwgMTIgTWF5IDIwMTYgMTc6MTQ6MzIgQ1NUOjg3MjkzODMwMA==
            x-bce-request-id: bb90cc9c-2b80-462c-87a4-095e610c9a2f
            Transfer-Encoding: chunked
            {
                "code":"InternalError",
                "message":"We encountered an internal error. Please try again.",
                "requestId":"52454655-5345-4420-4259-204e47494e58"
            }
          Previous
          UploadPart
          Next
          Service Related Interfaces