Log on to the Function Compute console.
Click Triggers on the code execution page.
Set the trigger type as Object Storage Service (OSS), and select the new bucket.
oss:objectCreated:*as the trigger event, and source/ as the prefix.
This configuration indicates that the function is triggered immediately when a new object is created with a source/ prefix in the bucket.
In Invocation Role Management, select Select an existing role. The system provides a role named
AliyunOSSEventNotificationRolefor the OSS trigger, and you can select this role directly as the trigger role.
The trigger needs to set a trigger role to authorize the execution of the function. OSS needs to play this role to trigger the function. For more information on permissions, see User permissions.
After the OSS trigger is set, you can test the entire project. You can upload a new image to the corresponding source/ directory in the Bucket in OSS console, and you find a new resized image of the same name in the processed/ directory.