Help Center/ Object Storage Service/ SDK Reference/ Python/ Object-Related APIs (SDK for Python)/ Using CRC64 to Verify File Consistency (SDK for Python)
Updated on 2025-12-11 GMT+08:00

Using CRC64 to Verify File Consistency (SDK for Python)

  • CRC calculation is a compute-intensive process that requires a large number of shift, exclusive OR (XOR), and table lookup operations. Enabling CRC consumes additional time, and the larger the data volume, the more CPU time is required. In C extension mode, calculating CRC for 1 GB of data takes about 4 to 6 seconds.
  • The OBS SDK for Python requires crcmod to calculate CRC checksums, and crcmod depends on the Python.h file in the python-devel package. crcmod supports both the C extension mode and the Python mode. If there is no Python.h file in the system, the OBS SDK for Python can still be installed, but the C extension mode of crcmod will fail to be installed. In this case, when calculating CRC checksums during upload or download, the system will use the pure Python mode, whose performance and efficiency are far lower than those of the C extension mode. Therefore, before installing the OBS SDK for Python, ensure that python-devel has been installed. If it is not installed, disable CRC64 verification.

You can use the following APIs to verify file consistency using CRC64 during uploads:

You can use the following APIs to verify file consistency using CRC64 during downloads:

You can use the following APIs to obtain the CRC64 value of an object:

Sample Code 1: Uploading Objects - Text-Based

Sample Code 2: Uploading an Object - File-Based

Sample Code 3: Uploading an Object - Append

Sample Code 4: Uploading an Object - Resumable

Code Example 5: Multipart Upload

Sample Code 6: Downloading an Object - File-Based

Sample Code 7: Downloading an Object - Resumable

Sample Code 8: Downloading an Object - Binary

Sample Code 9: Downloading an Object - Streaming

Sample Code 10: Downloading an Object - Range-Based

Sample Code 11: Obtaining Object Metadata