Help Center/ Object Storage Service/ API Reference/ APIs/ Advanced Bucket Settings/ Setting an Online Decompression Policy
Updated on 2024-04-22 GMT+08:00

Setting an Online Decompression Policy

Functions

Sets the policy for decompressing ZIP files in a bucket. The API is idempotent. If there is already the same rule for the bucket, a success message is returned with status code 200, or status code 201 is returned.

Request Syntax

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

policy json body

Request Parameters

This request contains no message parameters.

Request Headers

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

Request Elements

Table 1 Request elements

Parameter

Description

Mandatory

rules

Number of rules.

Type: container

Value range: [1, 10]

NOTE:

For the same bucket, prefixes of different rules cannot contain each other or have duplicate beginning characters. The same agency is recommended.

Yes

Table 2 Rule parameters

Parameter

Description

Mandatory

id

Name of a decompression policy. It is the unique ID of the decompression policy configured for the current bucket.

Type: string

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.

Yes

project

Project ID.

Type: string

Yes

agency

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

Type: string

Yes

events

Trigger event type.

Type: string

Supported event types:

["ObjectCreated:*"]
["ObjectCreated:Put"]
["ObjectCreated:Post"]
["ObjectCreated:Copy"]
["ObjectCreated:CompleteMultipartUpload"]

Yes

prefix

Rule prefix.

Type: string

Value range: [0, 1023]

No

suffix

Rule suffix.

Type: string

Fixed value: .zip

Yes

overwrite

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

Type: integer

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

Yes

decompresspath

Path for storing decompressed files. This parameter must end with a slash (/) if it is not empty.

Type: string

Value range: [0, 800]

No

policytype

Type of the decompression policy.

Type: string

Fixed value: decompress

Yes

The total length of the decompression policy name, decompression path, and IAM agency name cannot exceed 800 characters.

Response Syntax

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

Response Headers

The response to the request uses common headers. For details, see Table 1.

Response Elements

This response contains no elements.

Error Responses

No special error responses are returned. For details about error responses, see Table 2 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