tencent cloud

masukan

CRC64 Check

Terakhir diperbarui:2022-01-10 12:36: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
    • 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://intl.cloud.tencent.com/document/product/436/13318?from_cn_redirect=1
         var crc64 = data.headers['x-cos-hash-crc64ecma'];
         console.log(crc64);
       }
    });
    
    Hubungi Kami

    Hubungi tim penjualan atau penasihat bisnis kami untuk membantu bisnis Anda.

    Dukungan Teknis

    Buka tiket jika Anda mencari bantuan lebih lanjut. Tiket kami tersedia 7x24.

    Dukungan Telepon 7x24