List Buckets

It returns a list of all buckets.

AWS CLI

  1. Setup and configure AWS CLI, if not done already.
    aws s3api list-buckets

Python ( using boto3)

  1. Setup and configure boto3, if it is not done already.
    #!/bin/python import boto3
  2. Create connection resource and client
    s3 = boto3.resource("s3", endpoint_url = "https://s3.us-west-1.idrivecloud.io") client = boto3.client('s3', endpoint_url = "https://s3.us-west-1.idrivecloud.io")
  3. List buckets
    for bucket in s3.buckets.all(): print(bucket.name)

CURL

Request below uses AWS signature v2. Set the environment as per the steps below

s3AccessKey="" s3SecretKey="" date='date +%Y%m%d' dateFormatted='date -R' relativePath="/" contentType="application/json" stringToSign="GET\n\n${contentType}\n${dateFormatted}\n${relativePath}" signature='echo -en ${stringToSign} | openssl sha1 -hmac ${s3SecretKey} -binary | base64'
curl "https://s3.us-west-1.idrivecloud.io/" \ -H "Host: s3.amazonaws.com" \ -H "Content-Type: ${contentType}" \ -H "Authorization: AWS ${S3AccessKey}:${signature}=" \ -H "Date: ${dateFormatted}"

Node

Request below uses AWS signature v2. Set the environment as per the steps below

const http = require('http'); Request below uses AWS signature v2. Set the environment as per the steps below s3AccessKey="" s3SecretKey="" date='date +%Y%m%d' dateFormatted='date -R' relativePath="/" contentType="application/json" stringToSign="GET\n\n${contentType}\n${dateFormatted}\n${relativePath}" signature='echo -en ${stringToSign} | openssl sha1 -hmac ${s3SecretKey} -binary | base64'
const http = require('http'); const init = { host: 's3.us-west-1.idrivecloud.io' path: '/' port: 443 method: 'GET' headers: { 'Host': 's3.amazonaws.com', 'Content-Type': '${contentType}, 'Authorization': 'AWS ${S3AccessKey}:${signature}', 'Date': '${dateFormatted}' } };
const callback = function(response) { let str = ''; response.on('data', function(chunk) { str += chunk; });
response.on('end', function() { // str has response body console.log(str); }); };
const req = http.request(init, callback); req.end();