Configure decompression rules to automatically extract ZIP packages uploaded to a specified OSS directory. Function Compute decompresses the packages and saves the extracted objects to the destination directory.
Prerequisite
Function Compute is activated. To activate it, go to the Function Compute page.
Scenarios
-
Batch upload: Compress many small objects into a single ZIP package to reduce upload time.
-
Resource completeness: Bundle related files into one ZIP package to ensure all components are uploaded together.
-
Directory structure preservation: Package a local directory tree into a ZIP file and upload it to OSS. The decompression rule recreates the original folder structure in the bucket.
-
Content delivery: Compress objects into a ZIP package and upload it to OSS. The package is decompressed to specified directories, reducing transmission time and bandwidth usage.
How it works
OSS uses Function Compute to decompress uploaded ZIP packages. The following figure shows the process.
-
A ZIP package is uploaded to the directory specified by the Prefix parameter in a decompression rule.
-
The Function Compute trigger is invoked.
When you configure a decompression rule, authorize the trigger so that OSS can use the AliyunOSSEventNotificationRole role to access Function Compute.
-
Function Compute decompresses the ZIP package and saves the extracted objects to the specified OSS directory.
When you configure a decompression rule, authorize Function Compute to read from and write to the OSS bucket.
Billing
ZIP package decompression incurs fees in both OSS and Function Compute. Data transfers between OSS and Function Compute over internal endpoints are free of charge.
-
On the OSS side, you are charged for API operation calling and object storage. For more information, see Billing overview.
-
On the Function Compute side, you are charged for vCPU usage, memory usage and disk usage based on the execution duration. For more information, see Billing overview.
For example, if a ZIP package decompression task uses a Function Compute instance that has 3 GB of memory and a 2-core vCPU and takes 5 minutes to complete decompression, and the default size of the disk allocated for temporarily created storage files is 10 GB, the amount of the fees charged by Function Compute is calculated based on the following formula:
|
Resource usage item |
Unit |
Formula |
Billing example |
|
vCPU usage |
vCPU-seconds |
Active vCPU usage = vCPU capacity × Execution duration (seconds) |
If the function is configured with 2 vCPUs and runs for 300 seconds, the vCPU usage for a single run is calculated by using the following formula: 2 ×300 = 600 vCPU-seconds. |
|
Memory usage |
GB-seconds |
Memory usage = Memory capacity (GB) × Execution duration (seconds) |
If the function is configured with the memory size of 3GB and runs for 300 seconds, the memory usage for a single run is calculated by using the following formula: 3 ×300 = 900 GB-seconds |
|
Disk usage |
GB-seconds |
Disk usage = Disk capacity (GB) × Execution duration (seconds) Note: Disk usage up to 512 MB is free of charge. |
If the function is configured with a temporary disk size of 10 GB and runs for 300 seconds, the disk usage for a single run is calculated by using the following formula: (10-512/1024) × 300 = 2850 GB-seconds. |
Limitations
-
Storage classes: A Cold Archive object must be restored before it can be decompressed. An Archive object in a bucket for which real-time access of Archive objects is not enabled must also be restored before it can be decompressed.
-
Object and directory naming: Encode object and directory names in UTF-8 or GB 2312. Other encodings may cause decompression failures or garbled names.
-
Object size and decompression duration: Each object in a ZIP package cannot exceed 1 GB. You can increase the decompression duration if necessary. For more information, What do I do if a ZIP package fails to be decompressed due to a decompression timeout?
Configure a ZIP package decompression rule
Log on to the OSS console.
In the left-side navigation pane, click Buckets. On the Buckets page, find and click the desired bucket.
-
In the left-side navigation tree, choose .
-
Click Decompress ZIP Package. In the Decompress ZIP Package panel, configure the parameters described in the following table.
Parameters
Parameter
Required
Description
Service Authorization
Yes
Authorize Function Compute to read from and write to OSS and to execute functions.
Click Authorize. Complete authorization on the page that appears.
Authorize Trigger
Yes
Authorize OSS to access Function Compute.
Click Authorize. Complete authorization on the page that appears. If OSS is authorized to access Function Compute, the Trigger Role parameter is displayed instead of the Authorize Trigger parameter.
Prefix
No
The prefix that ZIP package names must match to trigger decompression. If you upload a ZIP package whose name contains this prefix or upload it to the directory specified by the prefix, Function Compute decompresses it. If not specified, all ZIP packages uploaded to the bucket are decompressed.
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 can I avoid trigger loops?
Destination Directory
No
The directory where extracted objects are stored. If not specified, objects are decompressed to the root directory of the bucket.
-
To store extracted objects in a subdirectory named after the ZIP package, select Add the compressed object name to the destination directory.
-
To store extracted objects directly in the destination directory without a subdirectory, select Decompress to the destination directory. The following table shows configuration examples.
WarningTo prevent service disruption, data contamination, or data loss when configuring rules for ZIP package decompression on a bucket with OSS-HDFS enabled, do not set the Destination Directory to
.dlsdata/.Decompression configuration examples
Scenario
Configuration method
Storage structure after decompression
Decompress all ZIP packages uploaded to the zipfolder directory to the destfolder directory, without creating subdirectories that have the same names as the ZIP packages.
-
Set Prefix to zipfolder/.
-
Set Destination Directory to destfolder.
-
Select Decompress to the destination directory.
bucket ├─── zipfolder/ │ ├─── a.zip│ └─── b.zip└─── destfolder/ ├─── a.txt ├─── b.txt └─── ...Decompress all ZIP packages uploaded to the zipfolder directory to the subdirectories that have the same names as the packages in the root directory of the bucket.
Configure the following parameters:
-
Set Prefix to zipfolder/.
-
Leave Destination Directory empty.
-
Select Add the compressed object name to the destination directory.
bucket ├─── zipfolder/ │ ├─── a.zip│ └─── b.zip├─── a/│ ├─── a.txt│ └─── ...└─── b/ ├─── b.txt └─── ...Decompress all ZIP packages uploaded to the zipfolder directory to the subdirectories that have the same names as the packages in the destfolder directory.
Configure the following parameters:
-
Set Prefix to zipfolder/.
-
Set Destination Directory to destfolder.
-
Select Add the compressed object name to the destination directory.
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.
Modify a ZIP package decompression rule
Modify a decompression rule to update the trigger prefix or function configurations.
Modify the Prefix parameter
-
On the Decompress ZIP Package page in the OSS console, find the trigger that you want to modify and click Edit in the Actions column.
-
On the Triggers tab of the function details page, find the trigger and click Modify in the Actions column.
-
In the Modify Trigger panel, modify the Object Prefix parameter and retain the default settings for other parameters.
-
Click OK.
Modify function configurations
-
On the Configurations tab of the function details page, click Modify in the Basic Settings section or the Environment Information section.
-
Modify the function configurations, such as Memory and Execution Timeout Period.
For more information, see Manage functions.
Delete a trigger
Deleted triggers cannot be restored. Deleting a trigger does not interrupt ongoing decompression tasks.
-
On the Triggers tab of the function details page, find the trigger that you want to delete and click Delete in the Actions column.
-
In the message that appears, click Delete.
