tencent cloud

All product documents
Serverless Cloud Function
DocumentationServerless Cloud FunctionPractical TutorialCOS PracticesImplementing Custom Calculation of File Hash Value with SCF + COS
Implementing Custom Calculation of File Hash Value with SCF + COS
Last updated: 2024-12-02 16:35:34
Implementing Custom Calculation of File Hash Value with SCF + COS
Last updated: 2024-12-02 16:35:34

Overview

Errors may occur when data is being transmitted between the client and the server. Cloud Object Storage (COS) combined with Serverless Cloud Function (SCF) can ensure the integrity of uploaded data through data verification, for example, MD5 verification. When users upload files to COS, SCF will help verify the objects uploaded by the users to ensure the integrity and correctness of the uploaded data.

Background

None of the existing public cloud object storage services in the industry provides MD5 verification, and after a user uploads a file, the following situations may occur:
Duplicated files and rising costs
File errors and lower business efficiency
File missing

Solution Strengths

Visual operation: One-click configuration simplifies the development process without coding, greatly improving R&D efficiency
Multiple options: MD5, SHA1, SHA256, and CRC64 are available, meeting user requirements in various scenarios
Automatic execution: Once a file is uploaded to COS, the workflow for calculating the verification code is triggered

Directions

1. Log in to the COS console.
2. Create a workflow, customize the format filter rule, and create a custom function node. For detailed directions, see Configuring Workflow.

3. In the function node pop-up window, click Add Function.
4. On the SCF creation page, select the template for COSHashCalculate.

5. Based on the user's file size, configure the execution timeout duration in the basic settings and configure sufficient memory in the advanced settings.
6. Configure the function code. This function template supports the following two environment variables:
hashTypeList: Indicates the list of calculation algorithms. This variable is optional. The default value is ["crc64", "md5", "sha1", "sha256"].
caseType: Indicates the hash case. This variable is optional. The default value is lowercase. You can also pass in uppercase.
7. Enable permission configuration and bind a role that has the read/write permission of the current bucket. To create an execution role, see Role and Authorization.
8. Click Complete.
9. Go back to the previous workflow page, select the custom transcoding function created just now, and save the workflow.

10. Upload the file. After the workflow processing is successful, you can see that multiple hash headers are successfully added to the uploaded file.

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

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
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon