Object Storage Service (OSS) is a secure, cost-effective, and highly reliable cloud storage service provided by Alibaba Cloud. OSS enables you to store a large amount of data in the cloud. After OSS is integrated with Function Compute, OSS events can trigger relevant functions to customize data processing in OSS buckets.

Background information

OSS is seamlessly integrated with Function Compute by using OSS event triggers. You can define functions and trigger the functions by using OSS events to customize data processing in OSS buckets. When OSS detects an OSS event of a specified type, this event triggers a corresponding function. For example, you can define a function to process a PutObject event. When you call the PutObject operation of OSS to upload an image to OSS, this function will be automatically triggered to process the image.

After OSS is integrated with Function Compute, you can call various functions to process images or audio data and then write the results to multiple storage services. In the entire architecture, you only need to focus on defining the function logic. Function Compute can reliably process large volumes of data in real time and in parallel.

Definition of OSS events

When OSS detects an event, OSS encodes the event information as a JSON string and passes it to the corresponding event processing function. The following table lists the supported OSS events.

Event Description
oss:ObjectCreated:PutObject The PutObject operation is called to upload files. For more information, see PutObject.

A function will be triggered after the operation is called.

oss:ObjectCreated:PutSymlink The PutSymlink operation is called to create a symbolic link for TargetObject in OSS, so that you can use this symbolic link to access TargetObject. For more information, see PutSymlink.

A function will be triggered after the operation is called.

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.

A function will be triggered after the operation is called.

oss:ObjectCreated:CopyObject The CopyObject operation is called to copy an existing object in OSS. For more information, see CopyObject.

A function will be triggered after the operation is called.

oss:ObjectCreated:InitiateMultipartUpload Before the MultipartUpload mode is used to transmit data, the InitiateMultipartUpload operation is called to notify OSS to initialize a MultipartUpload event. For more information, see InitiateMultipartUpload.

A function will be triggered after the operation is called.

oss:ObjectCreated:UploadPart After a MultipartUpload event is initialized, data can be uploaded in parts based on the specified object name and upload ID. For more information, see UploadPart.

A function will be triggered after the operation is called.

oss:ObjectCreated:UploadPartCopy The UploadPartCopy operation is called to upload a part by copying data from an existing object. For more information, see UploadPartCopy.

A function will be triggered after the operation is called.

oss:ObjectCreated:CompleteMultipartUpload After all parts are uploaded, the CompleteMultipartUpload operation is called to complete multi-part uploading of the entire file. For more information, see CompleteMultipartUpload.

A function will be triggered after the operation is called.

oss:ObjectCreated:AppendObject The AppendObject operation is called to upload a file in append mode. For more information, see AppendObject.

A function will be triggered after the operation is called.

oss:ObjectCreated:* A function will be triggered when one of the preceding ObjectCreated operations is called.
oss:ObjectRemoved:DeleteObject The DeleteObject operation is called to delete an object. For more information, see DeleteObject.

A function will be triggered after the operation is called.

oss:ObjectRemoved:DeleteObjects The DeleteObjects operation is called to delete files in batches.

A function will be triggered after the operation is called.

oss:ObjectRemoved:AbortMultipartUpload The AbortMultipartUpload operation is called to abort a MultipartUpload event based on the upload ID that you provide. For more information, see AbortMultipartUpload.

A function will be triggered after the operation is called.

Note A maximum of 10 trigger rule events can be created in a bucket.

Trigger rules

When you use OSS event triggers, make sure to avoid loops. For example, in a scenario where files are uploaded to an OSS bucket, the upload operation triggers a function. This function then generates one or more files that are written to the OSS bucket, and the write operation triggers this function again. This results in a loop.

To avoid costs incurred by loops as described in the preceding example, we recommend that you add prefixes or suffixes to directories. For example, you can set the src/ prefix for the bucket directory where a function is triggered, and the dst/ prefix for the directory to which files generated by the function are written. This prevents the function from being triggered again by the generated files.

If the same event type is specified for different triggers of a bucket, prefixes or suffixes cannot be repeated. Assume that a trigger is configured with the oss:ObjectCreated:PutObject event, the source prefix, and the zip suffix. The following table lists whether the bucket can be configured with other triggers.

Event Prefix Suffix Valid Description
oss:ObjectCreated:PutObject source zip No Both the prefix and suffix are the same as the prefix and suffix configured for the existing trigger.
oss:ObjectCreated:PutObject source None No The prefix is the same as the prefix configured for the existing trigger. No suffix is set, and objects with the zip suffix are included.
oss:ObjectCreated:PutObject None zip No The suffix is the same as the suffix configured for the existing trigger. No prefix is set, and objects with the source prefix are included.
oss:ObjectCreated:PutObject source1 1zip Yes The prefix and suffix are different from the existing ones.
oss:ObjectCreated:PutObject source zip1 Yes The suffix is different from the suffix configured for the existing trigger.
oss:ObjectCreated:PutObject 1source zip Yes The prefix is different from the prefix configured for the existing trigger.
oss:ObjectCreated:PostObject source zip Yes The event is different from the event configured for the existing trigger.
Note

If you want a trigger to trigger multiple functions, you can use Function Compute with the serverless workflow service. You can first use a trigger to trigger a function. Then, the function starts a serverless workflow, in which you can call multiple functions. For more information, see the example.