With Gcore Object Storage, you can utilize S3-compatible software, such as AWS CLI and S3cmd.
AWS CLI, or the AWS Command Line Interface, is the software for managing AWS services and has been integrated with our Object Storage for managing your buckets using commands from Amazon's official documentation.
1. Follow the instructions in the Amazon article to install the latest version of the AWS CLI.
2. To verify that the installation was successful, run the aws --version command in the terminal.
aws --version
The installation was successful if you see the version and your operating system in the output. For example:
aws-cli/2.7.24 Python/3.8.8 Windows/10 exe/AMD64 prompt/off
If the terminal cannot find the "aws" command, there may have been an issue during the installation. Please refer to the "Troubleshooting AWS CLI errors" guide for assistance.
1. Enter the aws configure command, and a configuration wizard will be launched.
2. You need to provide the following information:
Note: Do not change the other parameters.
3. To verify the configuration was successful, run the following command:
aws s3 ls --endpoint-url=https://s-ed1.cloud.gcore.lu
Replace https://s-ed1.cloud.gcore.lu with your storage endpoint, which can be found in the "S3 service URLs and default region names" guide.
Since there are no buckets in the storage, the command will not list anything. However, if there are no errors, you have configured the credentials correctly.
S3cmd is a free command line tool for uploading, retrieving, and managing data in Amazon S3 and other cloud storage services. Please use the commands described in the official S3cmd documentation.
1. Go to the "Download" section in the S3cmd documentation.
2. Download the repository for your operating system.
3. Install the latest version of S3cmd.
1. Enter the following command to launch the configuration wizard:
s3cmd --configure
2. You need to specify the following information:
Note: Do not change the other parameters.
S3cmd will try to connect to your storage. If the data is entered correctly, you'll receive the message:
Success. Your access key and secret key worked fine :-)
S3cmd will save the entered information in the ~/.s3cfg file in the following format:
[default]
access_key = 123ABC456DEF...
secret_key = EXAMPLE...
host_base = s-ed1.cloud.gcore.lu
host_bucket = s-ed1.cloud.gcore.lu
This method allows you to enter configuration data in one line without using a wizard.
Enter the command:
s3cmd --access_key 12*****6DEF --secret_key EX***** --host s-ed1.cloud.gcore.lu --host-bucket s-ed1.cloud.gcore.lu
Where:
The methods described below are relevant for AWS JavaScript SDK version 2.742.0.
To connect the interface with your storage, add AWS SDK to your HTML page according to the following example:
<html>
<head>
<script src="[https://sdk.amazonaws.com/js/aws-sdk-2.742.0.min.js](https://sdk.amazonaws.com/js/aws-sdk-2.742.0.min.js)"></script>
<script src="./js/index2.js"></script>
</head>
<body>
<h1>List of files</h1>
<ul id="list">
</ul>
</body>
</html>
Open the configuration file (./js/index2.js) and specify the data of your storage and future bucket:
var s3BucketName = "test";
var host = "https://s-ed1.cloud.gcore.lu";
var access\_key = "1234";
var secret\_key = "5678";
AWS.config.accessKeyId = access\_key;
AWS.config.secretAccessKey = secret\_key;
AWS.config.endpoint = host;
var s3 = new AWS.S3({
sslEnabled: true
});
Where:
Below is the wildcard policy example. It describes a configuration that allows cross-origin GET HEAD PUT, POST, and DELETE requests from all sources.
Note: This configuration can be insecure.
<CORSConfiguration>
<CORSRule>
<ID>Allow
everything</ID>
<AllowedOrigin>\*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<AllowedHeader>\*</AllowedHeader>
<MaxAgeSeconds>30</MaxAgeSeconds>
</CORSRule>
</CORSConfiguration>
After the configuration is completed, apply it to the bucket with the following command:
s3cmd setcors cors.xml s3://<bucket_name>
The example shows how to add two objects (test_file1 and test_file2) to the s3test bucket.
The example shows how to get a list of files in the test_2 bucket.
params = {
Bucket: "test_2"
};
s3.listObjects(params, function(err, data) {
if (err) return;
data.Contents.map(function(info){
var ul = document.getElementById("list");
var li = document.createElement("li");
li.innerText = info.Key + " " + info.LastModified;
ul.append(li);
});
});
Was this article helpful?
Check out our Storage