当前位置:网站首页>[play with Huawei cloud] Huawei cloud zero code development image compression tool

[play with Huawei cloud] Huawei cloud zero code development image compression tool

2022-06-09 18:03:00 Hua Weiyun

1. Preface

Register Huawei cloud account 、 Real name authentication

​ If you have a Huawei account and have passed the real name authentication , Can directly experience .

​ If the account has not passed the real name authentication , please Register Huawei account number , Then finish Real name authentication ( Recommended “ Code scanning authentication ” The way , Immediate completion ). Reference resources How to real name authentication and How to scan code for authentication .

2. Resources to prepare

2.1 establish OBS bucket

step 1 Sign in Object storage service console , single click “ Creating buckets ”, Get into “ Creating buckets ” Interface .

You need to create two OBS bucket , It is used to save the pictures uploaded by the user and the compressed pictures .

image-20220609131333863

​ step 2 Create two OBS Source bucket “picture-input2” Used to upload pictures ; Target bucket “picture-output2”, Store the output picture OBS bucket .

image-20220609142838921

image-20220609142923008

step 3 If you are prompted that the bucket name is duplicate , It can be changed by the user , And remember the bucket names corresponding to the upload bucket and the output bucket , For subsequent processes .

The creation is complete .

image-20220609142949765

step 4 After the bucket is created ,OBS The bucket list has two buckets .

2.2 Create delegation

1) Sign in Unified identity authentication service console , single click “ Create delegation ”.

image-20220609151412358

2) Start configuring delegates , The details are as follows . Configure delegation

image-20220609152113599

3) Click next to select “Tenant Administrator” jurisdiction ( Users with this permission can perform arbitrary operations on all cloud resources owned by the enterprise ), Because the permission list is long , It is recommended that users search and match in the upper right search box .

image-20220609152150432

4) Click next after checking permission , Select the scope of authority according to business needs and click OK , The delegate is now created ( Wait after the delegate is created 15-30 Minutes to take effect ).

image-20220609152235605

2.3 Create a function

When building functions , You must select a delegate that contains OBS Delegation of access rights , Otherwise you can't use it OBS service .

​ step 1 Sign in Function workflow console , choice “ Function templates ”. On the function template page , Search for “obs The compressed image ”.

image-20220609152758648

step 2 Fill in the function configuration information

​ 1) Basic information configuration

image-20220609153343372

2) Environment variable configuration

image-20220609153730140

explain :

​ key obs_address The format of the value is obs.{region}.myhuaweicloud.com,region Value , Please refer to Regions and terminal nodes .

​ key ThumbnailBucket Value is the name of the output bucket you created .

​ 3) Complete function creation

​ 4) stay “ Set up ” Tab , Configure memory and timeout

image-20220609153931591

2.4 Add dependency

The user enters the function details page , stay “ Code ” Tab , single click “ add to ”, Add the dependent package shown in the figure below , There are many dependent packages , It is recommended that the search box at the top right search for a match , Click OK... When the addition is complete , And click save... At the top right of the page .

image-20220609155123392

2.5 establish OBS trigger

step 1 Set the tab in the navigation bar , Click in the upper left corner to create the trigger , Create trigger .

12.png

3. The test results

Sign in Object storage service console , Click the bucket name to enter picture-input bucket , And click the left navigation bar “ object ” Button to enter the object interface , Click on “ Upload object ”, Upload an optional picture ( Note that the picture name cannot contain Chinese and Chinese symbols ), The example uses picture.jpg.

13.png

​ Get into picture-output Bucket object interface , You can see the compressed picture resize-picture.jpg, The size of the picture is 1.28KB, Realize the compression of pictures .

14.png

原网站

版权声明
本文为[Hua Weiyun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206091735479314.html