This topic describes how to use Function Compute to download multiple objects as a package to a local computer.


  • Function Compute is activated.

    You can activate Function Compute on the buy page. For more information, see Function Compute.

  • Function Compute is authorized to access Object Storage Service (OSS).

    For information about how to perform authorization, see Permissions.

Background information

When you download multiple objects from OSS at a time, the download speed may be affected if the sizes of the objects are small and the number of the objects is large. To resolve this issue, use Function Compute to compress the objects into a package. Then, download the package to your local device and decompress the package. The following flowchart shows the process of how to use Function Compute to compress the objects into a package and download objects. Decompress objects

Process details:

  1. A user calls a function and specifies a bucket and the objects to compress.
  2. Function Compute obtains the specified objects from OSS and randomly generates a name for the ZIP package.
  3. Function Compute uploads the ZIP package to OSS.
  4. Function Compute returns the URL to download the ZIP package to the user.
  5. The user uses the returned URL to download the ZIP package from OSS.
  • The disk space used to run the function is limited. Streaming download and streaming upload are used to transfer the ZIP package. Only a small amount of data is cached in the buffer.
  • To accelerate the transfer of the ZIP package, Function Compute uploads the ZIP package to OSS while Function Compute generates the ZIP package.
  • When the ZIP package is uploaded to OSS, multipart upload is used to upload parts. Multi-threading is supported.
  • It takes a maximum of 10 minutes for Function Compute to compress objects. Test data: It takes about 63s to upload 57 objects whose total size is 1.06 GB.


Linux is used in this example. To use Windows and macOS, modify corresponding commands.

  1. Install FunCraft.
    For more information about how to install FunCraft, visit Install FunCraft.
  2. Download the code package used to run the function.
  3. Decompress the code package.
  4. Modify the event.json file. Specify the location of the objects to compress.
    vi event.json
       "region": "regionid",
       "bucket": "bucketname",
       "source-dir": "path/"
    • region: Enter the ID of the region where your bucket is located. Example: cn-hangzhou.
    • bucket: Enter the name of the bucket.
    • source-dir: Enter the folder of the objects to compress. Example: ./. We recommend that you store all objects to compress in a directory.
  5. Enter fun deploy to deploy the function. Record the URL value.
  6. Use curl to trigger the function.
    curl -v -L -o /localpath -d @./event.json urlvalue
    Command used in this example:
    curl -v -L -o /test/ -d @./event.json https://174649585760****