Bucket commands

Last Updated: May 04, 2017

config

Command instructions:

config --id=[accessid] --key=[accesskey] --host=[host] --sts_token=[sts_token]

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 will perform authentication in STS method.

Example:

  • python osscmd config --id=your_id --key=your_key
  • python osscmd config --id=your_id --key=your_key --host=oss-internal.aliyuncs.com

getallbucket(gs)

Command instructions:

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 very risky as it will erase all the data and the erased data cannot be restored. Use it with caution.


Command instructions:

deletewholebucket oss://bucket

Delete bucket and its objects as well as 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, refer to API Reference.

Example:

  • python osscmd putlifecycle oss://mybucket lifecycle.xml

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

  1. <LifecycleConfiguration>
  2. <Rule>
  3. <ID>1125</ID>
  4. <Prefix>log_backup/</Prefix>
  5. <Status>Enabled</Status>
  6. <Expiration>
  7. <Days>2</Days>
  8. </Expiration>
  9. </Rule>
  10. </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

Command instructions:

osscmd putreferer oss://bucket --allow_empty_referer=[true|false] --referer=[referer]

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 white list for access, e.g., “www.test1.com,www.test2.com”, with “,” as the separator. For detailed rule configuration, refer to Product documentation.

Example:

  • python osscmd putreferer oss://mybucket --allow_empty_referer=true --referer="www.test1.com,www.test2.com"

getreferer

Command instructions:

osscmd getreferer oss://bucket

Get the anti-leech rules of the bucket.

Example:

  • python osscmd getreferer oss://mybucket

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.

Example:

  • python osscmd putlogging oss://mybucket oss://myloggingbucket/mb

getlogging

Command instructions:

osscmd getlogging oss://bucket

Get the logging rules of the bucket and an xml file will be returned.

Example:

  • python osscmd getlogging oss://mybucket
Thank you! We've received your feedback.