🎉 Announcing new lower pricing — up to 40% lower costs for Cloud Servers and Cloud SQL! Read more →

Contents

Using S3cmd with Orbit

This guide will take you through installing and configuring S3cmd to manage files on Orbit object storage.

S3cmd is a command line tool for uploading, retrieving and managing data in Amazon S3 and other cloud storage service providers that support the S3 protocol, such as Orbit.

Prerequisites

For the purposes of this guide, we’ll assume that you have already:

  1. Signed up with a Brightbox account
  2. Created an Orbit container and API Client

You’ll need the following details:

  • Orbit container name
  • API client (cli-xxxxx)
  • API client secret

Install S3cmd

For our guide we’re using Ubuntu Linux so we can use apt to install S3cmd but you can also install S3cmd on macOS via Homebrew.

$ sudo apt update
$ sudo apt install s3cmd -y

If you need the very latest releases, you’ll need to download and install from the official sources.

Configuring s3cmd

If you’re using S3cmd manually, you can create a config file to save having to specify commandline options each time.

s3cmd has an interactive config tool, but there are many options which aren’t relevant or won’t work with Orbit so it’s easier to just create the config file directly. Create ~/.s3cfg with the following content:

[default]
access_key = <api_client_id>
secret_key = <api_client_secret>
host_base = orbit.brightbox.com
host_bucket = orbit.brightbox.com
bucket_location = gb1
use_https = true

Using S3cmd without a config

Of course, you don’t necessarily need a config to use S3cmd – you can just specify all of the options on the commandline each time, which is how you might use it with scripts.

$ s3cmd --host=orbit.brightbox.com --host-bucket=orbit.brightbox.com \
--region=gb1 --access_key=<api_client_id> --secret_key=<api_client_secret> \
ls s3://my-container
2024-04-26 13:36     10485760  s3://my-container/archive.tar.gz

Listing files

Now that we have configured S3cmd we should be able to access our Orbit container and list the contents:

$ s3cmd ls s3://my-container
2024-04-26 13:36     10485760  s3://my-container/archive.tar.gz

Downloading files

To download a file from an Orbit container we use the s3cmd get command:

$ s3cmd get s3://my-container/archive.tar.gz
download: 's3://my-container/archive.tar.gz' -> './archive.tar.gz'  [1 of 1]
10485760 of 10485760   100% in    1s     7.66 MB/s  done

Uploading files

To upload a file to an Orbit container, use the s3cmd put command:

$ s3cmd put my_image.jpg s3://my-container
upload: 'my_image.jpg' -> 's3://my-container/my_image.jpg'  [1 of 1]
1147623 of 1147623   100% in    0s     2.24 MB/s  done

We can upload the entire contents of a directory by including the --recursive flag:

$ s3cmd put my-directory/ s3://my-container/my-directory/ --recursive
upload: 'my-directory/file1.txt' -> 's3://my-container/my-directory/file1.txt'  [1 of 3]
6148 of 6148   100% in    0s    13.16 KB/s  done
upload: 'my-directory/file2.txt' -> 's3://my-container/my-directory/file2.txt'  [2 of 3]
10 of 10   100% in    0s    32.65 B/s  done
upload: 'my-directory/file3.txt' -> 's3://my-container/my-directory/file3.txt'  [3 of 3]
10 of 10   100% in    0s    32.68 B/s  done

Deleting files

To delete a file we can use s3cmd del:

$ s3cmd del s3://my-container/archive.tar.gz
delete: 's3://my-container/archive.tar.gz'

To delete a path and its contents include the --recursive flag:

$ s3cmd del s3://my-container/my-directory/ --recursive
delete: 's3://my-container/my-directory/file1.txt'
delete: 's3://my-container/my-directory/file2.txt'
delete: 's3://my-container/my-directory/file3.txt'

Last updated: 15 May 2024 at 15:07 UTC

Try Brightbox risk-free with £50 free credit Sign up takes just two minutes...