This topic describes how to use Function Compute to implement features of a file management website, such as automatic file compression and decompression and image resolution processing.
An image website provides image tagging services and has the following requirements:
- Automatic package update
After a specific image is updated and an object is uploaded to a directory in Object Storage Service (OSS), specific objects in the directory need to be automatically compressed. The compressed package is distributed to different workgroups for processing. After the workgroups download the package, the MD5 value of the package need to be obtained to check whether the downloaded files are consistent.
- Automatic package decompressing
After specific images for public display are uploaded to OSS in packages, the packages must be automatically decompressed so that the images can be referenced by front-end pages, and the meta information of the images needs to be obtained to meet various requirements.
- Automatic image crawling
Specific material pictures need to be crawled from particular image groups on the website and added to material libraries.
- Automatic packaging
Some image groups contain a large number of images of various categories. The image groups are updated every now and then. When a user downloads images from one of these groups, the images need to be automatically packaged and distributed.
- Automatic screenshot taking and archiving, image resolution unification, and watermarking
- Capture screenshots of web pages at a regular basis and archive the screenshots.
- Apply unified resolutions and add watermarks to images.
The following figure shows the architecture of the solution.
In the preceding figure:
- When you perform a specific action, the corresponding OSS and HTTP triggers are triggered.
- Function Compute executes corresponding functions to perform specific operations on the images based on the passed parameters.
- In this process, all logs are written to the corresponding project of Log Service to facilitate debugging and query.
- Events and requests can be dynamically scaled to implement intelligent resource scheduling.
- You are charged only for used resources. The metering granularity is accurate to the millisecond.
- Files are processed on different ECS instances to ensure data security.