Bucket commands

config

Configure the default host, ID, and Key of the osscmd. The default host is oss.aliyuncs.com.To access oss-internal.aliyuncs.com, you can add —host=oss-internal.aliyuncs.com.The sts_token parameter is not requisite. When sts_token is filled, the tool performs authentication in STS method.

getallbucket(gs)

Show the bucket the user has created. The gs is the short form of get service. The gs achieves the same effect with getallbucket.

Example:

python osscmd getallbucket

python osscmd gs

createbucket(cb,mb,pb)

Command instructions:

createbucket(cb,mb,pb) oss://bucket --acl=[acl]

Create bucket commands. The cb is short for create bucket, mb is short for make bucket, pb is short for put bucket and oss://bucket indicates the bucket. The —acl parameter can be included but it is not required. The several commands all achieve the same effect.

Example:

python osscmd createbucket oss://mybucket

python osscmd cb oss://myfirstbucket --acl=public-read

python osscmd mb oss://mysecondbucket --acl=private

python osscmd pb oss://mythirdbucket

deletebucket(db)

Command instructions:

deletebucket(db) oss://bucket

Delete bucket commands. The db is short for delete bucket. Deletebucket achieves the same effect with db.

Example:

python osscmd deletebucket oss://mybucket

python osscmd db oss://myfirstbucket

deletewholebucket

Note: This command is highly risky as it erases all the data and the erased data cannot be restored. Use it with caution.

Command instructions:

deletewholebucket oss://bucket

Delete bucket, its objects, and the multipart contents.

Example:

python osscmd deletewholebucket oss://mybucket

getacl

Command instructions:

getacl oss://bucket

Get bucket access and control privilege.

Example:

python osscmd getacl oss://mybucket

setacl

Command instructions:

setacl oss://bucket --acl=[acl]

Modify bucket access and control privilege. The acl can only be one of the three, private, public-read, or public-read-write.

Example:

python osscmd setacl oss://mybucket --acl=private

putlifecycle

Command instructions:

putlifecycle oss://mybucket lifecycle.xml

Set lifecycle rules. The lifecycle.xml is the configuration file of lifecycle. For detailed rule configuration, see API Reference.

Example:

python osscmd putlifecycle oss://mybucket lifecycle.xml

The lifecycle.xml contains the configuration rules of lifecycle. E.g.:

<LifecycleConfiguration>

<Rule>

<ID>1125</ID>

<Prefix>log_backup/</Prefix>

<Status>Enabled</Status>

<Expiration>

<Days>2</Days>

</Expiration>

</Rule>

</LifecycleConfiguration>

getlifecycle

Command instructions:

osscmd getlifecycle oss://bucket

Get rules of the bucket lifecycle.

Example:

python osscmd getlifecycle oss://mybucket

deletelifecycle

Command instructions:

osscmd deletelifecycle oss://bucket

Delete all the lifecycle rules under the bucket.

Example:

python osscmd deletelifecycle oss://mybucket

putreferer

Set anti-leech rules. The allow_empty_referer parameter is requisite and used to set whether it is allowed to be null. The referer parameter is used to set the allowed whitelist for access, e.g., “www.test1.com,www.test2.com”, with “,” as the separator. For detailed rule configuration, see Product documentation.

getreferer

putlogging

Command instructions:

osscmd putlogging oss://source_bucket oss://target_bucket/[prefix]

The source_bucket indicates the bucket for logs, and the target_bucket indicates where the logs can be stored. You can set a prefix for the log files generated in the source bucket for the convenience of categorized query.