Help


Documentation & Tutorials

How to use Object Storage with s3cmd

Using Object Storage with s3cmd

This page shows you how to use Object Storage with s3cmd.

Requirements

Object Storage allows you to store any kind of objects (documents, images, videos, etc.). You can retrieve them anytime and from anywhere.

For instance, you can store images and they will be accessible using HTTP. You can use the control panel to manage your storage. As the our API is S3 compatible, a lot of tools exist to interact with the object storage.

This tutorial details how to use the Object Storage with s3cmd.

There are four steps to configure and use s3cmd:

  • Retrieving your Credentials
  • Downloading S3cmd
  • Configuring S3cmd
  • Using Object Storage with s3cmd

Retrieving your Credentials

To retrieve your credentials, refer to S3 credentials.

Downloading S3cmd

A simple solution to begin with Object Storage is to use the S3cmd tool, which is a client for S3 Object Storage.

S3cmd allows you to create, list and delete buckets, download, upload, and delete objects inside the Object Storage. Download S3cmd S3cmd on github.

If you use Linux or OS X, your package manager probably has a package for s3cmd.

Important: Make sure you have at least the version 2.0 (s3cmd --version). Upgrade s3cmd if it is not the case. Previous versions might not work properly.

Configuring S3cmd

1 . In a terminal, create a file named .s3cfg in your home directory.

2 . Replace access_key = <your_access_key> and secret_key = <your_secret_key> with your credentials.

$cat ~/.s3cfg

[default]
# Endpoint
host_base = https://s3.nl-ams.scw.cloud
host_bucket = https://s3.nl-ams.scw.cloud
bucket_location = nl-ams

# Login credentials
access_key = <ACCESS_KEY TO INSERT HERE>
secret_key = <SECRET_KEY TO INSERT HERE>

Using Object Storage with S3cmd

Creating a New Bucket

The following command creates a bucket to store objects with S3cmd. A bucket name must contain only alphanumeric and lowercase characters.

john@localhost:~$ s3cmd mb s3://mynewbucket

Bucket 's3://mynewbucket/' created
Uploading Object into the Bucket

The following command uploads movie1.avi and photo1.jpg into the bucket mynewbucket:

john@localhost:~$ s3cmd put movie1.avi photo1.jpg s3://mynewbucket

movie1.avi -> s3://mynewbucket/movie1.avi  [1 of 2]
 0 of 0     0% in    0s     0.00 B/s  done
photo1.jpg -> s3://mynewbucket/photo1.jpg  [2 of 2]
 0 of 0     0% in    0s     0.00 B/s  done

Listing Objects inside a Bucket

The following command lists the objects inside a bucket:

john@localhost:~$ s3cmd ls s3://mynewbucket

2014-09-10 08:44         0   s3://mynewbucket/movie1.avi
2014-09-10 08:44         0   s3://mynewbucket/photo1.jpg

Downloading an Object from a Bucket

The following command downloads the object movie1.avi locally:

john@localhost:~$ s3cmd get s3://mynewbucket/movie1.avi movie1.avi

s3://mynewbucket/movie1.avi -> movie.avi  [1 of 1]
 0 of 0     0% in    0s     0.00 B/s  done

Removing Object from a Bucket

The following command removes the object movie1.avi from the bucket mynewbucket:

john@localhost:~$ s3cmd del s3://mynewbucket/movie1.avi

File s3://mynewbucket/movie1.avi deleted

Removing a Bucket

The following command removes the bucket mynewbucket:

john@localhost:~$ s3cmd rb s3://mynewbucket

Bucket 's3://mynewbucket/' removed

Discover a New Cloud Experience

Deploy SSD Cloud Servers in seconds.