Object Storage Service (OSS) can automatically decompress ZIP files. To decompress files in other formats, such as .tar.gz, .tar.bz2, and .tar.xz, you can create an OSS event trigger in Function Compute and code the logic of the trigger to decompress such files. This topic describes how to automatically decompress files uploaded to OSS in different formats.
Decompress a large file
If a compressed file is large and contains many files, decompression may time out and fail to complete. Function Compute can work together with Serverless Workflow to decompress large numbers of files.
- Log on to the Function Compute console.
- In the left-side navigation pane, click Application Center.
- On the Application Center page, click Create Application Based on a Template.
- In the Create Application wizard, select Unzip Oss File and click Configure and Deploy in the Select Template
- On the Unzip Oss File page, set the parameters and click Deploy.Note This application is available only in the China (Hangzhou), China (Shanghai), China (Beijing), and China (Shenzhen) regions. Only ZIP files can be decompressed.
If this solution cannot meet your needs, contact us.
Configure decompression for different file formats
- You can perform the following operations to decompress the sample project:
- Modify and save the template.yml file.
- Change the value of the BucketName parameter to the name of your bucket.
- Change the value of the Project parameter from decompress-log-pro to the name of your project. Project names must be globally unique.
- When you configure the OSS event trigger, change the values of the Prefix, Suffix, and PROCESSED_DIR parameters as needed. PROCESSED_DIR specifies the directory where you want to save
decompressed files.Note OSS event triggers use the src/ prefix and the dst/ directory by default.
- In the directory that contains the template.yml file, run the
fun deploycommand to deploy your project.
- After your project is deployed, you can upload compressed files with a .zip, .tar.gz,
.tar.bz2, or .tar.xz extension to the specified directory in your bucket. When the
upload is successful, the function is triggered to decompress the files. The default
directory for storing compressed files is src/.The function automatically decompresses the files to the target directory. The default directory for storing decompressed files is dst.