Updated on 2026-07-27 GMT+08:00

Setting an Online Decompression Policy

Function

OBS can automatically decompress uploaded ZIP packages and save them to a specified directory. If any ZIP package uploaded to a bucket matches the configured decompression policy, the package will be automatically decompressed to the specified directory. You can call this API to configure a decompression policy for ZIP files in a bucket. For more information about online decompression, see Online Decompression.

The obscompresspolicy URI parameter is an OBS-defined sub-resource identifier for online decompression. Its API name DecompressPolicy directly expresses the decompression semantics of the policy.

Constraints

Permissions

  • To configure, obtain, or delete online decompression policies, you must have the Tenant Administrator permission assigned by using role/policy-based authorization of IAM.
  • Online decompression requires that you create an IAM agency to delegate OBS to access data in the bucket. The permissions the agency should assign to OBS include obs:object:PutObject, obs:object:GetObject, and obs:object:AbortMultipartUpload.

Package and file size

  • A single ZIP package cannot exceed 1 GB in size.
  • A single ZIP package can contain a maximum of 65,536 files.
  • A single decompressed file cannot exceed 40 GB in size.

Time

  • Decompressing a ZIP package takes 10 minutes at most.

Functions

  • Currently, only ZIP packages are supported.
  • ZIP package names cannot contain Chinese punctuation marks, special characters, or special codes.
  • To decompress the ZIP package that contains other ZIP packages, the event type of the online decompression policy must be set to ObjectCreated:* or ObjectCreated:CompleteMultipartUpload.
  • Currently, no notification will be sent to users after decompression tasks are complete.
  • Currently, only deflate-compressed ZIP packages can be decompressed. Deflate is different from the compression algorithms (such as Store and Normal) provided by WinRAR.
  • The total length of the decompression path plus the name of any decompressed file cannot exceed 512 characters.
  • Currently, encrypted ZIP packages cannot be decompressed.
  • Federated users cannot use the online decompression function. For more information about federated users, see What Are the Relationships Between a Huawei Cloud Account, HUAWEI ID, IAM User, and Federated User? and Identity Providers.

URI

PUT /

Calling Method

For details, see Calling APIs. Before calling this API, calculate the API signature and add it to the request.

You can debug this API in API Explorer.

Request Syntax

PUT /?obscompresspolicy HTTP/1.1
Host: bucketname.obs.region.myhuaweicloud.com 
Authorization: authorization
Content-Type: application/json
Content-Length: length
Date: date

{
	"rules": [{
		"id": "ruleid",
		"project": "your project id",
		"agency": "testagency",
		"events": ["ObjectCreated:*"],
		"prefix": "decompress",
		"suffix": ".zip",
		"overwrite": 0,
		"decompresspath": "after-decompress/",
                "policytype": "decompress"
	}]
}

URI Parameters

Parameter

Type

Description

obscompresspolicy

String

Definition

A query parameter in the URI that specifies the operation for an online decompression policy, passed without a value. It is used to distinguish between different policies of a bucket, meaning that this request is for the online decompression policy.

Constraints

N/A

Range

Empty (Only the key ?obscompresspolicy is required. No value is needed.)

Default Value

N/A

Request Headers

This request uses common headers. For details, see Table 3.

Request Body

Table 1 Request body parameters

Parameter

Mandatory

Type

Description

rules

Yes

Container

Definition

Array of rules.

Constraints

For the same bucket, prefixes of different policies cannot be the same or contain each other, suffixes cannot contain each other, and the same IAM agency is recommended.

Range

1 to 10 rules

Default Value

N/A

Table 2 rules parameters

Parameter

Mandatory

Type

Description

id

Yes

String

Definition

Name of a decompression policy. It is the unique ID of the decompression policy configured for the current bucket. The value can contain 1 to 256 characters, matching the regular expression of ^[a-zA-Z0-9_-]{1, 256}$. It consists of only uppercase letters, lowercase letters, digits, underscores (_), and hyphens (-), for example, event_0001.

Constraints

Only letters, digits, underscores (_), and hyphens (-) are allowed. The policy ID must be unique in a bucket.

Range

1–256

Default Value

N/A

project

Yes

String

Definition

Project ID.

Constraints

It cannot be empty and must be a valid project ID under the current tenant.

Range

A valid project ID under the current tenant

Default Value

N/A

agency

Yes

String

Definition

Agency name. With an agency, you can grant OBS the permissions to query whether a specified object exists in the bucket and to upload objects to the bucket.

Constraints

It cannot be empty and must be the name of an agency that has been authorized to OBS.

Range

Authorized agency name

Default Value

N/A

events

Yes

Array of String

Definition

Trigger event type.

Constraints

This parameter cannot be empty. Duplicate event types are not allowed. A wildcard event (for example, ObjectCreated:*) cannot be configured alongside its sub-events.

Range

  • ObjectCreated:*: A wildcard event that matches all object creation sub-events. It is triggered when any object creation operation is performed in a bucket, including sub-events like Put, Post, Copy, and CompleteMultipartUpload.
  • ObjectCreated:Put: An object creation sub-event through PUT upload. It is triggered when an object is created using a PUT request. It corresponds to the PUT Object API of OBS (direct upload of a complete object to a specified path).
  • ObjectCreated:Post: An object creation sub-event through POST upload. It is triggered when an object is created using a POST request. It corresponds to the POST Object API of OBS (form-based upload).
  • ObjectCreated:Copy: An object creation sub-event through replication. It is triggered when an existing object is replicated to a new path using a POST request. It corresponds to the COPY Object API of OBS.
  • ObjectCreated:CompleteMultipartUpload: An object creation sub-event through part assembling. If you upload a large file in multiple parts and call the API to assemble parts, this event is triggered when the parts are assembled into a complete object.

Default Value

N/A

prefix

No

String

Definition

Prefix defined in the rule.

Constraints

The length of the prefix or suffix cannot each exceed 1,024 characters , and the total length of the prefix and suffix cannot exceed 1,024 characters. For the same bucket, the combination of prefixes and suffixes of different policies cannot be the same or contain each other.

Range

1 to 1,024 characters

Default Value

N/A

suffix

Yes

String

Definition

Suffix defined in the rule.

Constraints

It must be the compressed file extension supported by the system. (Only .zip is supported currently.)

Range

.zip

Default Value

N/A

overwrite

Yes

Integer

Definition

Method of processing a decompressed file if it has the same name as an existing file.

Constraints

The value must be 0, 1, or 2. Other values are invalid.

Range

  • 0: Skip without overwriting.
  • 1: Do not overwrite (rename the file with the CRC32 value).
  • 2: Overwrite the existing file.

Default Value

N/A

decompresspath

No

String

Definition

Path for storing decompressed files. If the value is not empty, it must end with a slash (/) but cannot start with a slash (/).

Constraints

If the value is not empty, it must end with a slash (/) but cannot start with a slash (/). The total length of decompresspath, id, and agency cannot exceed 800 characters.

Range

The length of decompresspath ranges from 0 to 800 characters, and the total length of decompresspath, id, and agency cannot exceed 800 characters.

Default Value

N/A

policytype

No

String

Definition

Type of the decompression policy.

Constraints

The value must be decompress.

Range

decompress

Default Value

decompress

The total length of id, decompresspath, and agency cannot exceed 800 characters.

Response Syntax

HTTP/1.1 status
Server: OBS
Date: date
Content-Length: length

Response Headers

This response uses common headers. For details, see Table 1.

Response Body

This response contains no elements.

Error Responses

No special errors. You can find all errors in Error Code Overview and Table 3.

Sample Request

PUT /?obscompresspolicy HTTP/1.1
Host: bucketname.obs.region.myhuaweicloud.com 
Authorization: OBS H4IPJX0TQTHTHEBQQCEC:sc2PM13Wlfcoc/YZLK0MwsI2Zpo=
Content-Type: application/json
Content-Length: 497
Date: Tue, 21 Jul 2020 15:38:30 GMT

{
	"rules": [{
		"id": "ruleid",
		"project": "your project id",
		"agency": "testagency",
		"events": ["ObjectCreated:*"],
		"prefix": "decompress",
		"suffix": ".zip",
		"overwrite": 0,
		"decompresspath": "after-decompress/",
                "policytype": "decompress"
	}]
}

Sample Response

HTTP/1.1 201 Created
Server: OBS
Date: Tue, 07 Jul 2020 07:29:13 GMT
Content-Length: 0

Helpful Links