In this guide, we will learn how to use s3cmd as a client for ArvanCloud. S3cmd is a tool that allows you to create, list, or delete buckets from the terminal and download, upload, and delete objects to/from your bucket.
Installing S3cmd
You can install S3cmd from the command line using your Linux distribution’s Package Manager.
Enter the following command to update and upgrade your packages:
Enter the following command to install s3cmd:
S3cmd Configuration
Create a configuration file called .s3cfg in the HOME directory:
Open the file with a text editor like nano:
Copy and paste the following text into the file, then save and close it. Note that you must replace the value of your Access Key and Secret Key, which are in the front panel of the user panel in this file.
An alternative solution to creating a configuration file is to use the s3cmd –configure command.
Using Object Storage with S3cmd
The features available in the Object storage user panel or tools such as S3browser can be easily implemented with the help of S3cmd. In the following, we will examine the commands related to working with ArvanCloud Object storage using S3cmd.
Creating a New Bucket
Enter the following command to create a new bucket. Be careful that the bucket’s name must be a unique combination of numbers and small letters. Here we have chosen the name “newbucket”.
The output of the command will be similar to the following:
Uploading Files to a Bucket
You can use the following command to upload the file to the bucket:
The output of this command will be as follows:
Listing Files in a Bucket
To view the list of files in a bucket, use the following command. Here we list all the files in the “newbucket” bucket:
Downloading a File from the Bucket
Use the following command to download an object from the bucket to your system. For example, here we downloaded the logs.txt file from “newbucket”:
The output will be as follows:
Removing a File from the Bucket
You can use the following command to delete a file from the bucket. For example, here we delete the logs.txt file from the “newbucket”:
You should see the output as follows:
Deleting a Bucket
To delete a bucket, use the following command. Here we delete “newbucket”:
The output will be similar to the following:
CORS Configuration
The CORS standard allows browsers to request resources from other domains if they have permission. This feature helps you configure how your buckets are accessed from browser-based apps and websites.
Setting the CORS Configuration on a Bucket
Create a CORS configuration file and open it with a text editor:
Put your settings and configuration in the file, save and close it:
Use the following command and replace your bucket name with “bucketname” to set this information on it.
Removing CORS Settings from a Bucket
Run the following command to remove the CORS configuration of a bucket. Replace your bucket name with “bucketname”:
Other Commands
For more information about the various s3cmd commands, refer to the official documentation by running the “s3cmd –help” command.