s3cmd

s3cmd is a tool developed in Python that enables you to manage object storage buckets with Unix-like commands.

Installation

If you already have Python installed on your machine, s3cmd is available through the pip utility.

To install s3cmd, run the following command:

$ pip3 install s3cmd

Configuration

In this example, we configure s3cmd for the OUTSCALE Object Storage (OOS) service, on the eu-west-2 Region. For more information about OOS, see About OOS.

  1. Run the following command:

    $ s3cmd --configure
  2. Specify at least the following settings:

    • Your access key

    • Your secret key

    • Your Region

    • S3 Endpoint: oos.eu-west-2.outscale.com

    • DNS-style bucket+hostname: %(bucket)s.oos.eu-west-2.outscale.com

  3. In your home directory, open the .s3cfg file and modify the website_endpoint entry as follows:

    ~/.s3cfg
    website_endpoint = http://%(bucket)s.oos-website-%(location)s.oos.eu-west-2.outscale.com/

Examples

  • Creating a bucket:

    $ s3cmd mb s3://MY_BUCKET
  • Listing your buckets:

    $ s3cmd ls
  • Uploading an object to a bucket:

    $ s3cmd put OBJECT s3://MY_BUCKET

    You can set up rights as public when adding an object to your bucket by adding the following parameter:

    --acl-public
  • Copying an object:

    $ s3cmd cp s3://MY_BUCKET/OBJECT_TO_COPY s3://MY_BUCKET_FOR_THE_COPY
  • Listing the content of a bucket:

    $ s3cmd ls s3://my_bucket
  • Downloading an object from a bucket:

    $ s3cmd get s3://MY_BUCKET/OBJECT NEW_NAME_FOR_THE_DOWNLOADED_OBJECT
  • Deleting an object:

    $ s3cmd del s3://my_bucket/bar
  • Signing an OOS URL to provide limited public access with expiry:

    $ s3cmd signurl s3://my_bucket/my_file.png <expiry_in_epoch>
  • Allowing an object for one week:

    Allow file for 1 week
    $ s3cmd signurl s3://my_bucket/my_file.png $(echo "`date +%s` + 3600 * 24 * 7" | bc)
  • Deleting a bucket:

    $ s3cmd rb s3://MY_BUCKET

Related Pages