What do I do if a function is triggered multiple times when an object is uploaded to OSS?

Updated at: 2024-02-20 05:53

If an Object Storage Service (OSS) trigger is triggered multiple times when you upload an object to OSS, you must check whether the Trigger Event parameter is correctly configured.

Possible causes

The possible cause for repeated triggering of an OSS trigger when an object is uploaded is that the specified trigger rule contains wildcards. As a result, multiple events generated during the upload of a single object are matched and multiple function executions are triggered.

For example, if you use the multipart upload feature to upload an object to OSS, the oss:ObjectCreated:InitiateMultipartUpload, oss:ObjectCreated:UploadPart, and oss:ObjectCreated:CompleteMultipartUpload events are triggered in sequence. For example, if you set Trigger Event of an OSS trigger to oss:ObjectCreated:*, your function is triggered 5 times if you upload a 12 MB object by using OSS Browser and set the part size to 5 MB. The following items list the trigger events:

  • oss:ObjectCreated:InitiateMultipartUpload

  • oss:ObjectCreated:UploadPart

  • oss:ObjectCreated:UploadPart

  • oss:ObjectCreated:UploadPart

  • oss:ObjectCreated:CompleteMultipartUpload

Therefore, you must set Trigger Event to oss:ObjectCreated:CompleteMultipartUpload for multipart uploads to ensure that the trigger is triggered only once.

Solution

Remove wildcards from the matching rule and configure accurate events. For example, you can set Trigger Event for a trigger to oss:ObjectCreated:PutObject, oss:ObjectCreated:PostObject, and oss:ObjectCreated:CompleteMultipartUpload. The following items describe the details of these events:

  • oss:ObjectCreated:PutObject: creates or overwrites an object by using simple uploads.

  • oss:ObjectCreated:PostObject: creates or overwrites objects by using form uploads.

  • oss:ObjectCreated:CompleteMultipartUpload: completes multipart uploads.

  • On this page (1, T)
  • Possible causes
  • Solution
Feedback
phone Contact Us

Chat now with Alibaba Cloud Customer Service to assist you in finding the right products and services to meet your needs.

alicare alicarealicarealicare