This document describes how to use SCF to automatically decompress files in COS. COS is used to store uploaded .zip files and decompressed files, and SCF automatically decompresses .zip files uploaded to COS.
The main parameter information is as follows. Keep the remaining parameters as default:
mubucket
as an example.On the bucket management page, select Function Service on the left.
Click Add Function in "ZIP File Decompression Function". In the "Create ZIP File Decompression Function" window that pops up,
configure the following information.
PUT Object
or POST Object
API. When Create using Put method is selected as the event, only packages uploaded through the PUT Object
API will trigger decompression.Note:
If your file is uploaded to the bucket by means of simple upload, multipart upload, or cross-region replication, we recommend you select the File upload event.
Note:
If there is a containment relationship between the configured destination file prefix and the trigger condition, loop triggering may be caused, which should be avoided. For example, if the destination prefix is
prefix
and the trigger condition ispre
, decompression will be triggered repeatedly when apref
package is uploaded.
After adding the configuration, select Confirm, and you will see that the function has been added.
You can select View Log to view the history of decompression. If an error occurs during decompression, you can quickly enter the SCF Console to view the error details by selecting View Log. If you need to delete a file decompression rule no longer used, select Delete to delete the relevant configuration.
On the bucket management page, select File List on the left.
On the file list page, click Upload Files and select a .zip file for upload.
Refresh the current bucket to check whether files are generated after decompression.
Switch to Function Service to view the log or enter the SCF Console to view the execution result, and you will see the printed log information in Execution Log.
Was this page helpful?