Object Storage Service (OSS) is a secure, cost-effective, and highly reliable cloud storage service provided by Alibaba Cloud. OSS allows you to store a large amount of data in the cloud. After you integrate OSS with Function Compute, OSS events can trigger the execution of functions to process data in OSS buckets. This topic describes the types of OSS trigger events that are supported by Function Compute and the rules that are used to trigger native OSS triggers.
Background information
OSS is seamlessly integrated with Function Compute by using OSS event triggers. You can write functions and trigger the functions by using OSS events. When OSS captures an event of a specified type, the event triggers the execution of the corresponding function. For example, you can write a function to process PutObject events. When you call the PutObject operation of OSS to upload an image to OSS, the function is triggered to process the image.
After you integrate OSS with Function Compute, you can invoke various functions to process images and audio data and write the results to multiple storage services. In the entire process, you need to focus only on writing the function logic. Function Compute can process large amounts of data in real time and in parallel.
OSS events
When OSS captures an event, OSS encodes the event information as a JSON string and passes the JSON string to the function that processes the event. For more information about the format of OSS event notifications, see Event notifications.
The following table describes the types of OSS events that are supported by Function Compute. Each event type corresponds to an ObjectCreated, ObjectRemoved, or ObjectModified operation. After an operation is called as expected, the function is triggered and executed once.
Event type | Event name | Description |
---|---|---|
ObjectCreated | oss:ObjectCreated:PutObject | The PutObject operation is called to upload an object. For more information, see PutObject. |
oss:ObjectCreated:PutSymlink | The PutSymlink operation is called to create a symbolic link for a destination object in OSS. You can use this symbolic link to access the destination object. For more information, see PutSymlink. | |
oss:ObjectCreated:PostObject | The PostObject operation is called to upload a file to a specified bucket by using an HTML form. For more information, see PostObject. | |
oss:ObjectCreated:CopyObject | The CopyObject operation is called to copy an existing object in OSS. For more information, see CopyObject. | |
oss:ObjectCreated:InitiateMultipartUpload | Before you use multipart upload to upload data, the InitiateMultipartUpload operation must be called to notify OSS to initiate a multipart upload event. For more information, see InitiateMultipartUpload. | |
oss:ObjectCreated:UploadPart | After the multipart upload event is initiated, you can upload data in parts based on specified object names and upload IDs. For more information, see UploadPart. | |
oss:ObjectCreated:UploadPartCopy | The UploadPartCopy operation is called to copy data from an existing object to upload a part. For more information, see UploadPartCopy. | |
oss:ObjectCreated:CompleteMultipartUpload | The CompleteMultipartUpload operation is called to complete the multipart upload of an object. For more information, see CompleteMultipartUpload. | |
oss:ObjectCreated:AppendObject | The AppendObject operation is called to upload an object by appending the content of the object to an existing object. For more information, see AppendObject. | |
oss:ObjectCreated:* | A function is triggered when one of the preceding ObjectCreated operations is called. | |
ObjectRemoved | oss:ObjectRemoved:DeleteObject | The DeleteObject operation is called to delete an object. For more information, see DeleteObject. |
oss:ObjectRemoved:DeleteObjects | The DeleteMultipleObjects operation is called to delete multiple objects at a time. For more information, see DeleteMultipleObjects. | |
oss:ObjectRemoved:AbortMultipartUpload | The AbortMultipartUpload operation is called to cancel a multipart upload task based on the upload ID that you provide. For more information, see AbortMultipartUpload. | |
ObjectModified | oss:ObjectModified:UpdateObjectMeta | The UpdateObjectMeta operation is called to modify the attributes of an object. Note This type of event is supported in the following regions: China (Hangzhou), China (Shanghai), China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Shenzhen), and China (Chengdu). |
Rules for triggering native OSS triggers
Do not perform loop triggering
To prevent extra costs from being generated by loop triggering, we recommend that you specify the Object Prefix parameter or the Object Suffix parameter when you create an OSS event trigger. For example, you can set the prefix of the objects that are used to trigger function execution to src
and the prefix of the objects that are generated after the function execution to dst
. This way, the generated objects do not trigger the function again. If you do not specify the Object Prefix parameter or the Object Suffix parameter, objects with all prefixes and suffixes are matched. For more information, see Configure an OSS trigger.
Ensure the semantic uniqueness
The configuration semantics of a trigger must be unique across the bucket for which the trigger is created. The configurations include the Trigger Event parameter, the Object Prefix parameter, and the Object Suffix parameter. For example, you create a trigger whose trigger event is oss:ObjectCreated:PutObject for a bucket. The Object Prefix parameter and the Object Suffix parameter of the trigger are set to source and zip. The following table describes whether new triggers for the bucket are valid.
Trigger Event | Object Prefix | Object Suffix | Valid | Description |
---|---|---|---|---|
oss:ObjectCreated:* | source1 | zip1 | No | The new trigger is configured with the same type of event as the existing trigger. Note oss:ObjectCreated:* includes all ObjectCreated events. If you have created a trigger of the ObjectCreated event type in a bucket, you cannot create a trigger of the oss:ObjectCreated:* event type. Similarly, if you have created a trigger of the oss:ObjectCreated:* event type in a bucket, you cannot create a trigger of the ObjectCreated event. |
oss:ObjectCreated:PutObject | source | zip | No | The new trigger is configured with the same values for the Object Prefix and Object Suffix parameters as the existing trigger. |
source | None | No | The new trigger is configured with the same value for the Object Prefix parameter as the existing trigger. If you do not specify the Object Suffix parameter, objects with the zip suffix are included. | |
None | zip | No | The new trigger is configured with the same value for the Object Suffix parameter as the existing trigger. If you do not specify the Object Prefix parameter, objects with the source prefix are included. | |
source1 | zip1 | Yes | The new trigger is configured with different values for the Object Prefix and Object Suffix parameters from the existing trigger. | |
source | zip1 | Yes | The new trigger is configured with a different value for the Object Suffix parameter from that of the existing trigger. | |
source1 | zip | Yes | The new trigger is configured with a different value for the Object Prefix parameter from the existing trigger. | |
oss:ObjectCreated:PostObject | source | zip | Yes | The new trigger is configured with a different value for the Trigger Event parameter from the existing trigger. |