An error may occur when data is transferred between the client and server. OSS can return the CRC-64 value of objects uploaded through any of the methods provided. The client can compare the CRC-64 value with the value calculated on the local machine to verify data integrity.
Background information
OSS calculates the CRC-64 value for newly uploaded objects and stores the result as
metadata of the object. OSS then adds the x-oss-hash-crc64ecma
header to the returned response header, which indicates its CRC-64 value. This CRC-64
value is calculated based on Standard ECMA-182.
If the object exists in OSS before CRC-64 goes online, OSS does not calculate its CRC-64 value. Therefore, its CRC-64 value is not returned when the object is obtained.
Operation instructions
- The PutObject, AppendObject, PostObject, and MultipartUploadPart operations return the corresponding CRC-64 value. The client can obtain the CRC-64 value returned by the server after the upload is complete and can check it against the value calculated on the local machine.
- When the MultipartComplete operation is called, the CRC-64 value of the entire object is returned if each part has a CRC-64 value. However, if a part is uploaded before the CRC-64 goes online, the CRC-64 value is returned.
- The GetObject, HeadObject, and GetObjectMeta operations return the corresponding CRC-64
value (if any). After the GetObject operation is complete, the client can obtain the
CRC-64 value returned by the server and check it against the value calculated on the
local machine.
Note The GET request that includes the Range header returns the CRC-64 value of the entire object.
- The newly generated object or part may not have the CRC-64 value after copy related operations such as CopyObject and UploadPartCopy are complete.
Examples
The following code provides an example on how to use Python to use CRC-64 values to verify data transmission integrity:
OSS SDK support
The following table describes OSS SDKs, some of which support CRC-64 for downloads and uploads.
SDK | Support for CRC | Example |
---|---|---|
Java SDK | Yes | CRCSample.java |
Python SDK | Yes | object_check.py |
PHP SDK | No | None |
C# SDK | No | None |
C SDK | Yes | oss_crc_sample.c |
JavaScript SDK | No | None |
Go SDK | Yes | crc_test.go |
Ruby SDK | No | None |
iOS SDK | Yes | OSSCrc64Tests.m |
Android SDK | Yes | CRC64Test.java |