You need to enable JavaScript to run this app.
Volcano Engine Function as a Service

Volcano Engine Function as a Service

Copy page
Download PDF
Data processing
Automatically decompressing files uploaded to TOS in real time by using veFaaS
Copy page
Download PDF
Automatically decompressing files uploaded to TOS in real time by using veFaaS
This topic introduces how to use veFaaS to automatically decompress Zip files in real time when they are uploaded to Torch Object Storage (TOS).​
Scenario introduction​
In actual business scenarios, files often need to be uploaded to TOS for storage and usage. To improve efficiency, the business side usually packs up all the files into a Zip archive to upload. However, in practical use, you still need to manually decompress the corresponding Zip archives, which is very inconvenient. Function as a Service combined with TOS Trigger can help you achieve real-time automatic decompression of files after being uploaded to TOS to help you improve work efficiency.​
Limits​
  • It is recommended to avoid using Mac tools to compress files. If you must use the Mac tools to compress files, do not use Chinese characters in file names. Otherwise, this will cause the names of decompressed files to appear as garbled characters and the files cannot function properly.​
  • TOS Bucket and veFaaS functions must be in the same region.​
Prerequisites​
  • API Access Key​
  • Torch Object Storage​
  • Volcano Engine TOS has been activated.​
  • Create a bucket (TOS Bucket). For detailed operations, refer to Creating bucket.​
  • Volcano Engine Function as a Service​
  • Function as a Service has been activated.​
Procedure​
Step 1: create a function using a code template​
Use the Download compressed package from TOS, decompress, and upload files code template to create a function, and then configure the code information.​
  1. Log in to the veFaaS console.​
  1. In the top navigation bar, select the target region.​
  1. On the Function page, click Create function.​
  1. The key options on the page and their descriptions are shown below. For other options, see Creating event functions.​
  • ​
    Parameter​
    Description​
    Function type​
    Select Create [Event function].​
    Basic information​
    ​
    Name​
    Enter a function name according to the prompts on the page. Function names cannot be changed after created.​
    Function code​
    ​
    Runtime​
    Select Python 3.9.​
    Deployment method​
    Select Function template > Example for downloading a compressed package from TOS, decompressing, and uploading files.​
    ​
  1. Click Create to complete creating the function.​
  • After successfully creating the function, the system will automatically redirect to the Code tab of the function details page.​
  1. On the Code tab of the function, the code template has provided the business code for automatic decompression. You only need to configure the following information.​
  • ​
    Parameter​
    Description​
    ak​
    Enter the AK prepared in the prerequisites.​
    sk​
    Enter the SK prepared in the prerequisites.​
    endpoint​
    Enter the access domain of the intranet using the Endpoint (region node).​
    region​
    Region. The TOS Bucket must be in the same region as the function.​
    destination​
    This is the path where the Zip archive uploaded to TOS is stored after decompression.​
    ​
  1. Click Save to save the modified code.​
Step 2: Release the function​
Release the function code and configuration.​
  1. On the function details page, under the Code tab, click Install dependencies.​
  1. After the dependencies are installed, click Release in the upper-right corner of the page.​
  1. Select Latest as the function version. Other options can be configured as required.​
  1. Click Confirm to release the function.​
Step 3: Configure the TOS trigger​
Configure the rules of TOS trigger for the function.​
  1. On the function details page, switch to Trigger tab, and click Create Trigger.​
  1. Configure the Trigger information as required. For details, see Creating TOS triggers.​
  • ​
  • ​
    Parameter​
    Description​
    Trigger type​
    Select Torch Object Storage.​
    Trigger name​
    Customize the name of the Trigger according to the rules prompted by the interface.​
    TOS Bucket​
    Select the TOS Bucket you created according to the prerequisites above.​
    Trigger event​
    Select tos:ObjectCreated:Put and tos:ObjectCreated:CompleteUpload in this example.​
    warning​
    The options tos:ObjectCreated:Put and tos:ObjectCreated:CompleteUpload need to be selected if you about to upload a large file through multipart requests. Otherwise, you can just select tos:ObjectCreated:Put, which triggers the function after a simple object is uploaded.​
    Filter conditions​
    By setting filter conditions, you can precisely match the object range of the events to be listened to, thus effectively lowering trigger frequency and reducing costs. This example sets the prefix as origin. That is to say, uploading a Zip archive to the /origin path triggers the automatic decompression of the uploaded task.​
    ​
  1. Click Confirm to complete the creation of the TOS trigger.​
Validating results​
  1. On the Trigger tab of the current function, select the TOS Trigger created earlier. Click the name of Bucket to redirect to the corresponding Bucket in the TOS console.​
  1. Enter the origin/ directory, click Upload file to submit a Zip archive locally.​
  1. Enter the uncompressed/ directory and you can see the uploaded file is successfully unzipped to the uncompressed/origin directory.​
​
Last updated: 2026.08.19 14:06:07