Overview
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. Description
APIs that currently support CRC64 include:
APIs for simple upload
Multipart upload APIs
Upload Part: you can compare and verify the CRC64 value returned by COS against the value calculated locally. Complete Multipart Upload: returns a CRC64 value for the entire object only if each part has a CRC64 attribute. Otherwise, no value is returned. When you call the PUT Object - Copy, the CRC64 value is returned only if the source object has one. The HEAD Object and GET Object operations return the CRC64 value provided the object has one. You can compare and verify the CRC64 value returned by COS against that calculated locally. SDK Samples
Description
This API is used to verify the CRC64 value consistency of the object data when the object is uploaded or downloaded.
Sample request
The API for simple upload is used as an example. It is the same with other APIs.
cos.putObject({
Bucket: 'examplebucket-1250000000',
Region: 'COS_REGION',
Key: 'exampleobject',
StorageClass: 'STANDARD',
Body: fileObject,
onProgress: function(progressData) {
console.log(JSON.stringify(progressData));
}
}, function(err, data) {
if (err) {
console.log(err);
} else {
var crc64 = data.headers['x-cos-hash-crc64ecma'];
console.log(crc64);
}
});
Apakah halaman ini membantu?