Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use function to calculate package and download OSS file

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

What this article shares with you is about how to use function calculation to package and download OSS files, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article, without saying much, follow the editor to have a look.

Packaging and downloading multiple files stored on OSS is a common requirement, such as packaging and downloading a directory on OSS. In this way, the data transmitted by the network can be saved and the cost and download time can be reduced. This requirement can be easily realized by using function calculation.

Demand

Package and download multiple files stored on OSS, such as a directory on OSS. In this way, the data transmitted by the network can be saved and the cost and download time can be reduced.

Scheme

Use function calculation to compress multiple files into a zip, store them on OSS, return the address of the zip file, and the client downloads the file. The general client supports following the HTTP 302 jump address, so after the compression is completed, return a 302 address, and then follow this address to download the compressed file package.

Download function code: zip-oss-code.zip.

Implementation details

The disk space of the function running environment is limited, and only a small amount of data is cached in memory by means of streaming download and upload.

In order to speed up, upload to OSS while generating zip files

When uploading zip files to OSS, use the multipart upload feature of OSS to upload concurrently with multiple threads.

Experimental data

Experimental procedure

Prepare the files to be packaged on OSS

Put the files in a directory above OSS

Deployment function

Deploy functions using fun deploy

Trigger function (via HTTP trigger address)

Use the curl command to call the function directly

Cat

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report