tencent cloud

Feedback

CRC64 Check

Last updated: 2024-02-04 17:20:25

    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
    PUT Object and POST Object: you can get the CRC64 check value for your file from the response headers.
    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.
    The Upload Part - Copy operation returns a corresponding CRC64 value.
    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', /* 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);
    }
    });
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support