All Products
Search
Document Center

Function Compute:OSS triggers

Last Updated:Feb 28, 2026

Object Storage Service (OSS) triggers let Function Compute run your functions automatically when OSS events occur. When an object is created, deleted, modified, or replicated in a bucket, OSS fires an event that invokes the associated function. This enables real-time, event-driven processing of images, audio, logs, and other data at scale -- without managing infrastructure.

For example, uploading an image through the PutObject operation can trigger a function that generates thumbnails and stores them in another bucket.

How it works

  1. An OSS event occurs in a bucket (for example, a file upload or deletion).

  2. OSS encodes the event as a JSON string and passes it to the associated function. For the event payload format, see Event notifications.

  3. Function Compute runs the function and returns the result.

Native and EventBridge-based triggers

Function Compute supports two types of OSS triggers. Choose the type that fits your use case.

CapabilityNative OSS triggerEventBridge-based OSS trigger
Multiple file prefixes and suffixes per triggerNot supportedSupported
More than 10 triggers per bucketNot supportedSupported
Same event type triggering different functionsNot supportedSupported
Regular expression matching for prefix/suffixNot supportedNot supported
Note

For native OSS triggers, do not associate more than 10 triggers with a single bucket. Create a new bucket and set up triggers for it instead.

Supported event types

Each event type maps to an OSS API operation. When the operation completes, the function runs once.

ObjectCreated

Triggered when objects are added to a bucket.

Event nameAPI operationDescription
oss:ObjectCreated:PutObjectPutObjectUpload an object
oss:ObjectCreated:PostObjectPostObjectUpload an object through an HTML form
oss:ObjectCreated:CopyObjectCopyObjectCopy an existing object
oss:ObjectCreated:PutSymlinkPutSymlinkCreate a symbolic link to a target object
oss:ObjectCreated:AppendObjectAppendObjectUpload an object by appending data
oss:ObjectCreated:InitiateMultipartUploadInitiateMultipartUploadInitialize a multipart upload
oss:ObjectCreated:UploadPartUploadPartUpload a part in a multipart upload
oss:ObjectCreated:UploadPartCopyUploadPartCopyUpload a part by copying from an existing object
oss:ObjectCreated:CompleteMultipartUploadCompleteMultipartUploadComplete a multipart upload
oss:ObjectCreated:*All of the aboveAny ObjectCreated operation

ObjectRemoved

Triggered when objects are removed from a bucket.

Event nameAPI operationDescription
oss:ObjectRemoved:DeleteObjectDeleteObjectDelete a single object
oss:ObjectRemoved:DeleteObjectsDeleteMultipleObjectsDelete multiple objects in a batch
oss:ObjectRemoved:AbortMultipartUploadAbortMultipartUploadAbort a multipart upload

ObjectModified

Triggered when object metadata is updated.

Event nameAPI operationDescription
oss:ObjectModified:UpdateObjectMetaUpdateObjectMetaModify the properties of an object
Note

This event is supported only in the following regions: China (Hangzhou), China (Shanghai), China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Shenzhen), and China (Chengdu).

ObjectReplication

Triggered during data replication operations.

Event nameDescription
oss:ObjectReplication:ObjectCreatedA write operation during data replication
oss:ObjectReplication:ObjectModifiedAn overwrite operation during data replication
oss:ObjectReplication:ObjectRemovedA delete operation during data replication

Avoid loop triggering

Warning

Writing function output back to the same bucket that triggered the function creates an infinite loop. Each write triggers the function again, which generates more writes, leading to runaway invocations and costs.

Prevention: Use different file prefixes for input and output. For example, set the file prefix of the triggering object to src and the prefix of the generated output to dst. This way, output files do not match the trigger condition.

If no file prefix or suffix is configured, the trigger matches all objects in the bucket. For details, see Step 1: Create an OSS trigger.

Trigger conflict rules for native OSS triggers

Within a bucket, each native OSS trigger must have a unique combination of event type, file prefix, and file suffix. A new trigger can only be created if its combination does not conflict with an existing trigger.

A conflict exists when both of the following conditions are true:

  • Event type conflict -- The event types overlap. For example, oss:ObjectCreated:PutObject conflicts with oss:ObjectCreated:* because the wildcard is a superset of the specific event.

  • Path matching conflict -- Both the file prefix and file suffix match. Prefixes are matched from the start of the object name; suffixes are matched from the end.

If only one condition is true, there is no conflict and the trigger can be created.

Event type conflict

Existing trigger event typeNew trigger event typeConflict?
oss:ObjectCreated:PutObjectoss:ObjectCreated:*Yes. The wildcard includes PutObject.
oss:ObjectCreated:*oss:ObjectCreated:PostObjectYes. The wildcard includes PostObject.
oss:ObjectCreated:PutObjectoss:ObjectCreated:PostObjectNo. Different specific event types.

Path matching conflict

Existing trigger pathNew trigger pathConflict?
Prefix: source, Suffix: .zipPrefix: 1source, Suffix: .zipNo. Prefix does not match.
Prefix: source, Suffix: .zipPrefix: source, Suffix: .zip1No. Suffix does not match.
Prefix: source, Suffix: .zipPrefix: source, Suffix: .zipYes. Both prefix and suffix match.
Note

If the file prefix or file suffix is not set, it matches objects with any prefix or suffix. For example, if a new trigger has event type oss:ObjectCreated:PutObject, prefix source, and no suffix, it conflicts with an existing trigger that has event type oss:ObjectCreated:PutObject, prefix source, and suffix .zip -- because the empty suffix matches all suffixes, including .zip.

Configuration examples

The following table shows whether a new native OSS trigger can be created alongside an existing trigger with event type oss:ObjectCreated:PutObject, file prefix source, and file suffix zip.

New trigger event typeNew file prefixNew file suffixResultReason
oss:ObjectCreated:*sourcezipFailedEvent type conflict (wildcard includes PutObject) and path conflict (same prefix and suffix).
oss:ObjectCreated:PutObjectsource1zip1SuccessSame event type, but different prefix and suffix -- no path conflict.
oss:ObjectCreated:PutObjectsourcezipFailedSame event type and same prefix/suffix -- both conflicts exist.
oss:ObjectCreated:PutObjectsource1zipFailedSame event type; prefix matches, and 1zip ends with zip, so the suffix also matches.
oss:ObjectCreated:PutObjectsource1zipFailedSame event type; suffix matches, and source1 starts with source, so the prefix also matches.
oss:ObjectCreated:PutObjectsource(none)FailedSame event type; prefix matches, and an empty suffix matches all suffixes including zip.
oss:ObjectCreated:PutObject(none)zipFailedSame event type; suffix matches, and an empty prefix matches all prefixes including source.
oss:ObjectCreated:PutObjectsource1zip1SuccessSame event type, but different prefix and suffix.
oss:ObjectCreated:PutObject1source1zipSuccessSame event type, but different prefix and suffix.
oss:ObjectCreated:PostObjectsourcezipSuccessDifferent event type -- no event type conflict.
Important

To use the same OSS event type to trigger different functions for different processing tasks, create an EventBridge-based OSS trigger.

FAQ

References