All Products
Search
Document Center

Function Compute:Configure a ZIP package decompression trigger

Last Updated:Sep 05, 2025

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.

image
  1. 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.

  2. The Compute Function trigger is used.

  3. 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

  1. Log on to the OSS console. In the left-side navigation pane, click Buckets.

  2. On the Buckets page, click the name of the target bucket.

  3. In the left-side navigation pane of the bucket details page, choose Data Processing > ZIP Package Decompression. 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.

    Important

    If 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.

    Warning

    To 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
              └── ...
  4. 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

FAQ

Function Compute trigger fails after file upload

ZIP package decompression involves interactions between OSS and Function Compute. A ZIP package upload that matches an existing decompression rule triggers the decompression function in Function Compute to decompress the ZIP package. The OSS trigger to Function Compute may fail. You can check whether the decompression is successfully triggered by examining the value (Base64-encoded) of x-oss-event-status in the response header. If the decoded value of x-oss-event-status is {"Result": "Ok"}, the decompression is successfully triggered. If the decoded value of x-oss-event-status is not {"Result": "Ok"}, the decompression trigger fails. In this case, we recommend that you upload the ZIP package again. For more information, see Simple upload.

Note

The size of a single file in a ZIP package cannot exceed 10 GB, and the maximum time for decompressing a single package is 2 hours.

Decompression of large files fails after 2 hours

The function execution times out. You can adjust the function execution timeout period based on your needs, up to a maximum of 24 hours.

  1. In the OSS console, find the target bucket. On the Decompress ZIP Package page, click Edit to the right of the target trigger.

  2. In the function details page that appears, click the Configuration tab. In the left-side navigation pane, select Runtime, and then click Edit.

  3. In the runtime edit panel, modify the Execution Timeout, and then click Deploy.

ZIP package exceeds 10 GB, or a single file in the package exceeds 10 GB

If a ZIP package exceeds 10 GB or a single file in the package exceeds 10 GB, you can use NAS as a temporary working directory for decompression. This solution incurs a storage fee on Apsara File Storage NAS. For more information, see unzip-oss-nas.

Does the system support decompression of nested ZIP packages?

No, the system does not support decompression of nested ZIP packages.

If you configure a ZIP package decompression rule for a bucket, a ZIP package uploaded to the bucket triggers Function Compute to decompress the ZIP package only once. If the ZIP package contains another ZIP package, the inner ZIP package is not decompressed. You can upload the inner ZIP package separately to the bucket to trigger another decompression task.

Can files decompressed by FC be decompressed to a different bucket?

No, files decompressed by FC cannot be decompressed to a different bucket.

ZIP package decompression allows a ZIP package to be decompressed to a directory only within the bucket to which the ZIP package is uploaded. To decompress a ZIP package to a different bucket, you need to perform custom development in Function Compute.

Can I view files in the OSS directory during the decompression process?

Yes, you can view files in the OSS directory during the decompression process.

Function Compute uploads decompressed objects from a ZIP package to OSS while it decompresses the remaining data in the package.

How do I determine whether the decompression is complete?

You can check whether files have been decompressed to the destination directory in the file list of the target bucket, or check the function invocation logs in the Function Compute console to determine whether the decompression is complete.

  1. On the Decompress ZIP Package page in the OSS console, click Edit to the right of the target trigger.

  2. In the function details page that appears, click the Logs tab.

    If the logging feature is not enabled for the current function, click Enable With One Click.

  3. Upload a ZIP package, and then check whether the invocation is successful on the Logs tab.

Does the system support decompression of .rar and .tar.gz files?

No, the system does not support decompression of .rar and .tar.gz files.

ZIP package decompression supports only ZIP files. If you need to decompress other types of compressed files, see decompress-oss.

Does the system return information to OSS after a ZIP package is decompressed?

No, the system does not return information to OSS after a ZIP package is decompressed.

If you need to view the decompression progress, you can check the Invocation Logs tab on the function details page, or configure an asynchronous invocation destination service for the decompression function. For more information, see Configure an asynchronous invocation destination service.

Does OSS support online compression?

No, OSS does not support online compression.

You can use Function Compute to download objects from OSS to your local device as a package. For more information, see Use Function Compute to download objects from OSS as a package.

Does the system support multipart ZIP packages?

No, the system does not support multipart ZIP packages.

ZIP package decompression does not merge content from multipart ZIP packages. Therefore, the feature cannot decompress multipart ZIP packages.

The ZIP Package Decompression button is grayed out, and I cannot configure a ZIP package decompression rule

Check whether you have completed the required authorizations as prompted in the interface, such as creating the Function Compute service-linked role AliyunServiceRoleForFC or granting Function Compute permissions to upload files to OSS.