All Products
Search
Document Center

OSS decompresses ZIP files

Last Updated: May 31, 2019

OSS decompresses ZIP files

The OSS console supports the automatic decompressing of ZIP files. This feature also requires Function Compute. You need to configure the trigger in a required bucket in the OSS console. Currently, OSS can only decompress ZIP files. The following sections describe how to configure the feature and some cautions that you should pay attention to.

Architecture

Created with Raphaël 2.1.2ZIP fileZIP fileOSSOSSFunction ComputeFunction Computeuploads a ZIP file.automatically triggers the function and supports PUT and POST requests by default.decompresses the file.

Configure the OSS console

Go to the OSS console, select the required bucket, and then click the Function Compute tab, as shown in the following figure.001

Note: If you have not activated Function Compute, the system indicates that you activate Function Compute before performing the following operations.

Click the ZIP package unzip button to go to the page for editing the OSS trigger, as shown in the following figure.002Configure the following parameters on the edit page:

  1. Service Authorization: authorizes Function Compute to read from and write to OSS and to execute functions in the specified bucket in OSS. Click the Authorized button to set a RAM user. Each trigger requires the authorization.
  2. Trigger Role: authorizes OSS to access Function Compute. This setting is required only once.
  3. Prefix: specifies the prefix of files that trigger functions. We recommend that you set this parameter. If you do not set this parameter, the system matches all ZIP files in the bucket by default. As a result, functions may run cyclically. For more information, see FAQ.
  4. Target Directory: specifies the directory where you place extracted files. If you do not set this parameter, OSS extracts files to the current bucket by default.
  5. I agree to activate Function Compute and process zipped files using Function Compute.: Decompressing ZIP files is a value-added service. During the operation, Function Compute calculates billing based on the duration of decompression.

Modify a trigger

To modify a trigger, click Edit Trigger next to the required trigger to go to the page for modifying the trigger, as shown in the following figure.

003

You can modify the trigger event, prefix, and suffix. We recommend that you do not change the suffix, because the system has created functions based on the suffix to ensure normal service logic.

Modify a target directory

To modify the directory that you extract files to, click Edit under Function Properties on the Overview page. Then, change the environmental variables on the Basic settings dialog box that appears, as shown in the following figure.004

Delete a trigger

To delete a trigger in the OSS console, click Edit Trigger next to the target trigger to go to the page for editing the trigger. Then, click Delete to delete the trigger. We recommend that you delete the corresponding function so that OSS cannot decompress ZIP files.

Extend functions

Function Compute generates a system function that enables the OSS console to decompress ZIP files. You can modify function code as needed. For example, small ZIP files require little processing time, so you can specify lower memory to save costs. Similarly, for ZIP files of more than 1GB, we recommend that you set a longer timeout to minimize timeout occurrences.To decompress other types of files in addition to ZIP files, you can extend functions. Currently, Function Compute supports functions in Python2.7 by default.