Using GleSYS Object Storage with s3cmd

Introduction

S3cmd is a free tool used to upload, download and manage a service that's based on the S3 protocol. In this guide, we will help you to install and configure s3cmd. We will also create your first bucket using the GleSYS Object Storage service.

Install s3cmd

If you are running macOS you can install s3cmd using brew: brew install s3cmd

If you are using Debian or Ubuntu you can use the following command: apt-get install s3cmd

If you are using CentOS/RHEL use the following command: yum install s3cmd

If you are using Windows please follow ourguide "Installing s3cmd on Windows".

Configure s3cmd

With the installation done, it's time to run the configuration.

s3cmd --configure

Enter the following information:

Access Key: Your access key

Secret Key: Your secret key

Default region: dc-sto1

S3 Endpoint: objects.dc-sto1.glesys.net (without the https:// prefix)

DNS-style bucket+hostname:port template for accessing a bucket: %(bucket).objects.dc-sto1.glesys.net

In this guide we are not going to GPG-encrypt the files. You can therefore skip the next step "Encryption password och Path to GPG program" by pressing Enter

Use HTTPS protocol: Yes

Skip the HTTP Proxy server name step by pressing Enter.

Test access with supplied credentials?: Y

Save settings: Y

You are now done with the configuration and ready to start using the service.

Create your first bucket

By using s3cmd you can create a bucket for storing your objects. The name of the bucket can only be alphanumeric.

$ s3cmd mb s3://testbucket
Bucket 's3://testbucket/' created

You are now ready to upload your first file to the bucket. This can be done with your own application or with s3cmd (or any other S3 compatible application).

Upload and download files from your bucket

An empty bucket isn't much fun. You want files in it!

The command below will upload the file foo.bar to the bucket we just created. Uploading is done using the command put:

s3cmd put foo.bar s3://testbucket

To download the file you just uploaded use the command get:

s3cmd get s3://testbucket/foo.bar

List files

To list files in a specific bucket you use the command ls:

s3cmd ls s3://testbucket

To list all files in all buckets you can use la:

s3cmd la

Remove a file

To remove/delete a file in a bucket you use the command del:

s3cmd del s3://testbucket/foo.bar

Set access policies for anonymous read access

To be able to anonymously list and download files via http you need to set listingaccess on the bucket and set the right for downloading files. You do this with a policy.

Create a file with the name policy.txt. Copy and paste the text below into the file.

{
  "Version": "2012-10-17",
  "Statement":[
	{
  	"Effect":"Allow",
  	"Principal": "*",
  	"Action":["s3:ListBucket", "s3:GetObject"],
  	"Resource":["arn:aws:s3:::testbucket", "arn:aws:s3:::testbucket/*"]
	}
  ]
}

Upload the file to your bucket:

s3cmd put policy.txt s3://testbucket

Apply the new policy with setpolicy:

s3cmd setpolicy policy.txt s3://testbucket

You can now browse to https://testbucket.objects.dc-sto1.glesys.net/ and list all the files in the bucket.

Read more about policies

For a complete list of s3cmd command visit s3tools website.

Hittar du inte det du söker?

Kontakta oss gärna för mer information. Vi hjälper dig att komma fram till den bästa lösningen för dina behov.

Skicka e-post Ring 0200-23 88 00