tencent cloud

Step 2. Create and Test Thumbnail Function
마지막 업데이트 시간:2024-12-02 16:35:34
Step 2. Create and Test Thumbnail Function
마지막 업데이트 시간: 2024-12-02 16:35:34

Creating Thumbnail Function

1. Log in to the SCF console and select Function Service on the left sidebar.
2. At the top of the Function Service page, select the Guangzhou region and click Create to enter the function creating page and configure the function as shown below:
img


Creation method: select Template.
Template search: enter compression and search. This document uses the Python 2.7 runtime environment as an example. Click Learn More in the template to view relevant information in the Template Details pop-up window, which can be downloaded.
3. Click Next. The function name is automatically generated by default and can be modified as needed. Follow the prompts to configure the execution role:
img


Execution Role: check Enable. Configure and use SCF template role is selected here as an example as detailed below:
Configure and use SCF template role: select this option and the system will automatically create and select an SCF template execution role associated with full access permissions of COS.
Use the existing role: you need to select an existing role that contains the above permissions in the drop-down list.
Note:
During execution, the function will use the execution role to get a temporary key to manipulate relevant Tencent Cloud resources.
4. When using this template function, you need to modify the configuration information in the function code as prompted. Click to expand the Function Code block and replace appid, secret_id, secret_key, region, and resized_bucket in the function code with your APPID, SecretId, SecretKey, region, and resized_bucket
Note:
You can get the APPID on the Account Info page in the console.
You can get SecretId and SecretKey on the API Key Management page in the console.

Configuring COS Trigger

1. In the Trigger Configurations section, select Custom and configure as prompted as shown below:
img

Main parameters are as follows:
Trigger Method: select COS trigger.
COS Bucket: select the bucket mybucket created in Step 1.
Event Type: select All Creation Events.
2. Click Complete.

Testing Function

1. Switch to the COS console, select the created bucket mybucket1, click Upload File, and select a random .jpg or .png image for upload.
2. Switch to another COS bucket mybucket-resized1, check whether there is a file with the same name generated, download it, and compare the size of the two images.
3. Go to the SCF console to view the execution result. You can see the printed log information in Execution Logs.
문제 해결에 도움이 되었나요?
더 자세한 내용은 문의하기 또는 티켓 제출 을 통해 문의할 수 있습니다.
아니오

피드백