Errors may occur when data is transferred between the client and the server. COS can not only verify data integrity through MD5 and custom attributes, but also the CRC64 check code.
COS will calculate the CRC64 value of the newly uploaded object and store the result as object attributes. It will carry x-cos-hash-crc64ecma in the returned response header, which indicates the CRC64 value of the uploaded object calculated according to ECMA-182 standard. If an object already has a CRC64 value stored before this feature is activated, COS will not calculate its CRC64 value, nor will it be returned when the object is obtained.
APIs that currently support CRC64 include:
This API is used to verify the CRC64 value consistency of the object data when the object is uploaded or downloaded.
The API for simple upload is used as an example. It is the same with other APIs.
cos.putObject({
Bucket: 'examplebucket-1250000000', /* Required */
Region: 'COS_REGION', /* Bucket region. Required */
Key: 'exampleobject', /* Required */
StorageClass: 'STANDARD',
Body: fileObject, // Upload the file object.
onProgress: function(progressData) {
console.log(JSON.stringify(progressData));
}
}, function(err, data) {
if (err) {
console.log(err);
} else {
// You need to add `x-cos-hash-crc64ecma` to Expose-Headers for a successful response.
// Documentation: https://www.tencentcloud.com/document/product/436/13318?from_cn_redirect=1
var crc64 = data.headers['x-cos-hash-crc64ecma'];
console.log(crc64);
}
});
Apakah halaman ini membantu?