How to use function to calculate package and download OSS file
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