Object Storage Service (OSS) can automatically decompress ZIP packages. After you configure a decompression rule by specifying a file prefix and a destination directory, the system automatically decompresses ZIP packages that match the rule when you upload them to an OSS bucket, and writes the decompressed files to the destination directory. This feature integrates Function Compute (FC) with OSS, creating an OSS native trigger on the FC side that enables an event-driven process without requiring you to write code.
How the asynchronous inference and queue service work
OSS uses Function Compute to decompress uploaded ZIP packages. The following flowchart shows the decompression process.
A ZIP package with a name that matches the suffix in the decompression rule is uploaded to a directory that matches the prefix in the OSS decompression rule.
The Compute Function trigger is used.
Function Compute decompresses the ZIP package and saves the decompressed data to the specified OSS directory.
Scenarios
Batch Data Uploading
When you need to upload many small files, using a program to upload them one by one can be time-consuming. In this case, you can use the ZIP package decompression feature to package and upload the files.
Upload complete files
For resource integrity, sometimes multiple files need to be combined into a single resource. Uploading multiple files separately may have a lower success rate. In this case, you can use the ZIP package decompression feature to improve the upload success rate.
Upload files with a specific directory structure
Websites often reference many static resources with complex directory structures. Creating directories one by one in OSS and uploading files can be time-consuming. In this case, you can configure a ZIP package decompression rule, locally create a ZIP package that has an intended directory structure, and upload the ZIP package to OSS.
Resource distribution
When you need to distribute many files to users or different servers, you can package these files into a ZIP package and use the OSS ZIP package decompression feature to decompress the ZIP package to a specified directory. This reduces transmission time and bandwidth consumption.
Billing
Using the ZIP package decompression feature involves OSS storage fees and FC function invocation and resource usage fees, as detailed below.
OSS fees
Includes request fees for accessing bucket resources and storage fees for files stored in OSS buckets.
FC fees
Includes fees for function invocation counts and vCPU, memory, and disk resource usage generated by function calls. These metering items need to be converted to CU usage for billing according to conversion factors. For more information, see CU conversion factors.
Data transfer through bucket internal endpoints is free of traffic fees.
Limits
Storage class limitations
Files in Cold Archive or Deep Cold Archive storage classes must be restored before decompression. Files in Archive storage class must be restored before decompression if the Archive Direct Read feature is not enabled for the bucket.
File or folder naming limitations
We recommend that you encode your object or directory names in UTF-8 or GB 2312. Otherwise, the object or directory names after decompression may be garbled, or the decompression process may be interrupted.
ZIP package limitations
The size of a ZIP package cannot exceed 10 GB, and the size of a single file within the package cannot exceed 10 GB. The default maximum time for decompressing a single package is 2 hours. If the decompression takes longer than 2 hours, you can adjust the maximum function execution time. For more information, see Decompression of large files fails after 2 hours.
Configure ZIP package decompression trigger
Log on to the OSS console. In the left-side navigation pane, click Buckets.
On the Buckets page, click the name of the target bucket.
In the left-side navigation pane of the bucket details page, choose . Then, click ZIP Package Decompression. In the ZIP Package Decompression panel, configure the ZIP package decompression rule.
Parameter
Description
Example in this topic
Service Authorization
Create a service-linked role for Function Compute to access other Alibaba Cloud services. If you have not logged on to the Function Compute console before, you need to click the Authorize button to create the service-linked role AliyunServiceRoleForFC.
N/A
Function Authorization
Grant Function Compute permissions to read and write OSS.
Click the Authorize button and follow the prompts to complete the authorization.
N/A
Trigger Authorization
Authorize OSS to access Function Compute.
Click the Authorize button and follow the prompts to complete the authorization. If authorization is already completed, this item is displayed as Trigger Role.
N/A
Prefix
Configure the file prefix that triggers the function. If you upload a ZIP package whose name contains the specified prefix or upload a ZIP package to the directory specified by the prefix, Function Compute is triggered to decompress the ZIP package. If you do not specify this parameter, Function Compute decompresses all uploaded ZIP packages.
ImportantIf you do not specify this parameter, the decompression tasks may be repeatedly executed. Therefore, we recommend that you specify a prefix for each decompression rule. For more information, see How do I prevent circular triggers?.
zipfolder/
Destination Directory
Specify the directory in which the objects extracted from the ZIP package are stored. If you do not specify this parameter, Function Compute decompresses the ZIP package to the root directory of the current bucket. For different destination directory configurations, see the examples in this topic for the resulting file structures.
WarningTo avoid affecting the normal use of the OSS-HDFS service or risking data contamination or data loss, when configuring a ZIP package decompression rule in a bucket with OSS-HDFS service enabled, do not set the Destination Directory to
.dlsdata/.Destination directory is
destfolder, and Decompress Directly To Destination Directory is selected.bucket ├─── zipfolder/ │ ├─── a.zip │ └─── b.zip └─── destfolder/ ├─── a.txt ├─── b.txt └─── ...Destination directory is empty, and Keep Compressed File Name As Path Directory is selected.
bucket/ ├── zipfolder/ │ ├── a.zip │ └── b.zip ├── a/ │ ├── a.txt │ └── ... └── b/ ├── b.txt └── ...Destination directory is
destfolder, and Keep Compressed File Name As Path Directory is selected.bucket/ ├── zipfolder/ │ ├── a.zip │ └── b.zip └── destfolder/ ├── a/ │ ├── a.txt │ └── ... └── b/ ├── b.txt └── ...
Select I have read the terms of service and agreed to activate Function Compute and process compressed files by using Function Compute. Only file or folder names encoded in UTF-8 or GB 2312 can be processed. and click OK.
After the configuration is complete, you can modify the trigger's File Prefix and the associated FC function configuration. For more information, see Configure native OSS triggers and Configure functions.
References
If you need to automatically decompress other types of compressed files, such as
.taror.gzfiles, see decompress-oss.If you need to use Function Compute to download OSS files as a package, see Use Function Compute to download objects from OSS as a package.