Using the Object Storage Service – s3cmd
Presentation
The S3cmd is free software (GNU GPL license) developed by TGRMN Software to enable the use of AWS services through commands in a terminal (Linux shell or Terminal under OSX).
Similar to AWS CLI, S3cmd is, however, very limited in terms of IAM (identities and authorizations). It allows you to bypass the complexity of the S3 API to manipulate buckets and objects.
In particular, it offers a directory synchronization feature to/from S3 storage.
Configuration
Prerequisites:
· Have the current version of S3cmd installed (on Linux and macOS)
– See https://s3tools.org/download+and+https://github.com/s3tools/s3cmd/blob/master/INSTALL.md
Minimum configuration procedure:
- Open a command window.
- Run the command s3cmd –configure and enter:
- Key in the Access Key.
- Key in the Secret Access Key.
- Key in EU as the Default region.
- Key in the hostname for S3 Endpoint (see the service endpoint URL).
- “%(bucket)s.hostname” for DNS-style Bucket+hostname (see previous line)
- Confirm (do not enter anything) for Encryption password
- Confirm (do not enter anything) for Path to GPG program
- Confirm for Use HTTPS protocol (Yes by default)
- Confirm (do not enter anything) for HTTP Proxy server name
- Validate (do not enter anything) for Test access with supplied credentials (Y)
- After the message “Success. Your access key and secret key worked fine”, enter: y to Save the configuration (No by default)
NB: using the EU region does not mean that your data is located outside France; Cloud Avenue data is actually stored in mainland France.
Examples of use
In the following examples, url represents the hostname of your service endpoint accessible via HTTPS. You will need to modify it according to your endpoint (see your login information).
The examples correspond to simple use cases (bucket and object management).
Buckets
List buckets :
In the example, there are two Buckets (comp1 and comp2).
Listing the contents of a Bucket :
In the example, the comp1 bucket contains three files and a folder (or prefix) named backup. The contents of the folder are not listed here.
Recursively listing the contents of a bucket :
In the example, the comp1 Bucket contains four files, one of which is located in a folder named backup. The –recursive option allows you to list all objects, including those located in folders (or prefixes).
Creating a Bucket :
In the example, the empty Bucket comp3 is deleted.
Deleting a Bucket containing at least one object :
In the example, the comp2 partition is not empty; the –recursive option is used to automatically delete all objects and folders present.
Objects
Copying an object to a Bucket :
In the example, the local file is copied (uploaded) to the comp3 Bucket.
Copying an object to a folder :
In the example, the documentation folder is created if it does not already exist in the Bucket, then the local file is copied (uploaded) to the folder.
Renaming an object :
In the example, the file fic2.txt is renamed fic2bis.txt.
Moving an object :
Moving an object by renaming it :
Deleting an object :
In the example, the object is deleted; the documentation folder (or prefix) is empty; it is automatically deleted.
Deleting a folder or a prefix:
In the example, the deletion applies to the folder; the –recursive option causes all objects present to be deleted.