tencent cloud

Feedback

Step 2. Create and Test Thumbnail Function

Last updated: 2021-08-10 15:37:53

    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.

    1. 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

    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.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support