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.
Causes
The possible cause for repeated triggering of an OSS trigger may be that multiple specified triggering events are triggered during file upload.
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. 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.
Solutions
You can set the Trigger Event parameter of a trigger to oss:ObjectCreated:PutObject
, oss:ObjectCreated:PostObject
, or 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.