OCI Object Storage Classic Compatibility Matrix

Use Case Console OpenStack Swift API OpenStack Swift CLI OpenStack Swift Client OCI Classic FTM API OCI Classic FTM CLI OCI Classic Java SDK AWS Python SDK AWS Ruby SDK AWS CLI Terraform OCI Classic Provider Terraform OpenStack Provider Terraform AWS Provider s3cmd
Generate Authentication Token N Y Y Y N N N N N N N N N N
Create/Update Bucket Y Y Y Y Y N Y Y Y Y Y Y N Y
List Buckets Y Y Y Y Y Y Y Y N Y N N N N
Delete Bucket Y Y Y Y Y Y Y Y Y Y Y Y Y Y
Create/Update Bucket Metadata Y Y Y Y Y Y Y N N N N Y N N
Retrieve Bucket Metadata Y Y Y Y Y Y Y N N N N N N N
Delete Bucket Metadata Y Y Y Y Y N Y N N N N Y N N
Create/Update Object Y Y Y Y Y Y Y Y N N Y Y Y Y
List Objects Y Y Y Y Y Y Y Y N Y N N N Y
Retrieve Object Y Y Y Y Y Y Y Y Y Y N N N Y
Delete Object Y Y Y Y Y Y Y Y N Y Y Y Y Y
Create/Update Object Metadata N Y Y Y Y Y Y N N N N Y N N
Retrieve Object Metadata N Y Y Y Y Y Y Y Y Y N N N Y
Delete Object Metadata N Y Y Y Y N Y N N N N Y N N
Advertisements

OCI Object Storage Classic Tools

How to Delete Object Metadata in OCI Object Storage Classic

OpenStack Swift API w/ Java

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MediaType;

public class OciClassicSample {

  public static void main(String[] args) {
    Client client = ClientBuilder.newClient();

    client.target("https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject").request().header("X-Auth-Token", ...).header("X-Remove-Object-Meta-Sample-Key", "").post(Entity.entity("", MediaType.WILDCARD_TYPE));

    client.close();
  }

}

OpenStack Swift API w/ Go

package ociclassicsample

import "gopkg.in/resty.v1"

func main() {
  resty.R().SetHeader("X-Auth-Token", ...).SetHeader("X-Remove-Object-Meta-Sample-Key", "").Post("https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject")
}

OpenStack Swift API w/ Node.js

var https = require('https');

var req = https.request({ headers: { 'x-auth-token': ..., 'x-remove-object-meta-sample-key': '' }, hostname: 'host', method: 'POST', path: '/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject' });

req.end();

OpenStack Swift API w/ Python

import requests

requests.post('https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject', headers = { 'X-Auth-Token': ..., 'X-Remove-Object-Meta-Sample-Key': '' })

OpenStack Swift API w/ Ruby

require 'rest-client'

RestClient.post 'https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject', '', :x_auth_token => ..., :x_remove_object_meta_sample_key => ''

OpenStack Swift CLI

1) Configure the CLI:

export ST_AUTH=https://host/auth/v1.0
export ST_USER=sampleservice-sampleidentitydomain:sampleuser
export ST_KEY=samplepassword

2) Run the following command:

swift post samplebucket sampleobject -H "X-Remove-Object-Meta-Sample-Key:"

OpenStack Swift Client

from swiftclient.service import SwiftService

service = SwiftService({ 'auth': 'https://host/auth/v1.0', 'user': 'sampleService-sampleIdentityDomain:sampleUser', 'key': 'samplePassword' })

for res in service.post('sampleBucket', [ 'sampleObject' ], { 'header': [ 'X-Remove-Object-Meta-Sample-Key:' ] }):
  print res

OCI Classic FTM API

import java.util.HashMap;
import java.util.Map;

import oracle.cloudstorage.ftm.FileTransferAuth;
import oracle.cloudstorage.ftm.FileTransferManager;

public class OciClassicSample {

  public static void main(String[] args) {
    FileTransferManager ftm = FileTransferManager.getDefaultFileTransferManager(new FileTransferAuth("sampleUser", "samplePassword", "sampleService", "https://host/", "sampleIdentityDomain"));

    Map<String, String> metadata = new HashMap<String, String>();

    metadata.put("Sample-Key", "");

    ftm.setObjectMetadata("sampleBucket", "sampleObject", metadata, null);

    ftm.shutdown();
  }

}

OCI Classic FTM CLI

Not supported.

OCI Classic Java SDK

import oracle.cloud.storage.CloudStorage;
import oracle.cloud.storage.CloudStorageConfig;
import oracle.cloud.storage.CloudStorageFactory;

public class OciClassicSample {

  public static void main(String[] args) throws Exception {
    CloudStorage storage = CloudStorageFactory.getStorage(new CloudStorageConfig().setServiceName("sampleService-sampleIdentityDomain").setServiceUrl("https://host/").setUsername("sampleUser").setPassword("samplePassword"));

    storage.deleteObjectMetadata("sampleBucket", "sampleObject", "Sample-Key"); // omit the "X-Object-Meta" prefix
   }

}

AWS Python SDK

Not supported.

AWS Ruby SDK

Not supported.

AWS CLI

Not supported.

Terraform OCI Classic Provider

Not supported.

Terraform OpenStack Provider

1) Configure the provider:

export OS_SWAUTH=true
export OS_AUTH_URL=https://host/
export OS_USERNAME=sampleservice-sampleidentitydomain:sampleuser
export OS_PASSWORD=samplepassword

2) Delete the metadata values from the object configuration.

3) Apply the change.

Terraform AWS Provider

Not supported.

s3cmd

Not supported.

How to Retrieve Object Metadata in OCI Object Storage Classic

OpenStack Swift API w/ Java

import static java.lang.System.out;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;

public class OciClassicSample {

  public static void main(String[] args) {
    Client client = ClientBuilder.newClient();

    Response res = client.target("https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject").request().header("X-Auth-Token", ...).head();

    if (res.getStatus() == 200)
      res.getHeaders().forEach((k, v) -> out.println(k + " = " + v));

    client.close();
  }

}

OpenStack Swift API w/ Go

package ociclassicsample

import "gopkg.in/resty.v1"

import "fmt"

func main() {
  res, _ := resty.R().SetHeader("X-Auth-Token", ...).Head("https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject")

  if res.StatusCode() == 200 {

    for k, v := range res.Header() {
      fmt.Printf("%v = %v\n", k, v)
    }

  }

}

OpenStack Swift API w/ Node.js

var https = require('https');

var req = https.request({ headers: { 'x-auth-token': ... }, hostname: 'host', method: 'HEAD', path: '/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject' }, (res) => {

  if (res.statusCode === 200)
 
    for (k in res.headers)
      console.log(k + ' = ' + res.headers[k]);

});

req.end();

OpenStack Swift API w/ Python

import requests

res = requests.head('https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject', headers = { 'X-Auth-Token': ... })

if res.ok:
 
  for k, v in res.headers.items():
    print k + ' = ' + v + '\n'

OpenStack Swift API w/ Ruby

require 'rest-client'

res = RestClient.head 'https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject', :x_auth_token => ...

if res.code == 200
  res.headers.each {|k, v| puts "#{k} = #{v}" }
end

OpenStack Swift CLI

1) Configure the CLI:

export ST_AUTH=https://host/auth/v1.0
export ST_USER=sampleservice-sampleidentitydomain:sampleuser
export ST_KEY=samplepassword

2) Run the following command:

swift stat samplebucket sampleobject

OpenStack Swift Client

from swiftclient.service import SwiftService

service = SwiftService({ 'auth': 'https://host/auth/v1.0', 'user': 'sampleService-sampleIdentityDomain:sampleUser', 'key': 'samplePassword' })

for res in service.stat('sampleBucket', [ 'sampleObject' ]):
  print res

OCI Classic FTM API

import static java.lang.System.out;

import oracle.cloudstorage.ftm.FileTransferAuth;
import oracle.cloudstorage.ftm.FileTransferManager;
import oracle.cloudstorage.ftm.model.CloudObject;
import oracle.cloudstorage.ftm.model.ObjectMetadata;

public class OciClassicSample {

  public static void main(String[] args) {
    FileTransferManager ftm = FileTransferManager.getDefaultFileTransferManager(new FileTransferAuth("sampleUser", "samplePassword", "sampleService", "https://host/", "sampleIdentityDomain"));

    CloudObject obj = ftm.getObject("sampleBucket", "sampleObject");

    ObjectMetadata metadata = obj.getObjectMetadata();

    metadata.getCustomMetadata().forEach((k, v) -> out.println(k + " = " + v));

    ftm.shutdown();
  }

}

OCI Classic FTM CLI

1) Run the following command:

java -jar ftmcli.jar describe -U sampleuser -A https://host/ -S sampleservice -I sampleidentitydomain --save-auth-key samplebucket sampleobject

OCI Classic Java SDK

import static java.lang.System.out;

import oracle.cloud.storage.CloudStorage;
import oracle.cloud.storage.CloudStorageConfig;
import oracle.cloud.storage.CloudStorageFactory;
import oracle.cloud.storage.model.Key;

public class OciClassicSample {

  public static void main(String[] args) throws Exception {
    CloudStorage storage = CloudStorageFactory.getStorage(new CloudStorageConfig().setServiceName("sampleService-sampleIdentityDomain").setServiceUrl("https://host/").setUsername("sampleUser").setPassword("samplePassword"));

    Key obj = storage.describeObject("sampleBucket", "sampleObject");

    obj.getCustomMetadata().forEach((k, v) -> out.println(k + " = " + v));
   }

}

AWS Python SDK

import boto3

s3 = boto3.resource('s3', aws_access_key_id = 'sampleService-sampleIdentityDomain', aws_secret_access_key = 'sampleSecretAccessKey', endpoint_url = 'https://host/')

obj = s3.Object('sampleBucket', 'sampleObject')

for k in obj.metadata:
  print k + ' = ' + obj.metadata[k] + '\n'

AWS Ruby SDK

require 'aws-sdk-s3'
 
s3 = Aws::S3::Resource.new access_key_id: 'sampleService-sampleIdentityDomain', secret_access_key: 'sampleSecretAccessKey', endpoint: 'https://host/v1/sampleService-sampleIdentityDomain', force_path_style: true, region: 'us-east-1' # region is ignored
 
bucket = s3.bucket 'sampleBucket'
 
obj = b.object 'sampleObject'
 
obj.metadata.each {|k, v| puts "#{k} = #{v}" }

AWS CLI

1) Create the credentials file:

[default]
aws_access_key_id = sampleservice-sampleidentitydomain
aws_secret_access_key = samplesecretaccesskey

2) Run the following command:

aws s3api head-object --bucket samplebucket --endpoint-url https://host/ --key sampleobject

Terraform

N/A.

s3cmd

1) Create the .s3cfg file:

[default]
host_base = host
host_bucket = host
access_key = sampleservice-sampleidentitydomain
secret_key = samplesecretaccesskey

2) Run the following command:

s3cmd info s3://samplebucket/sampleobject

How to Create/Update Object Metadata in OCI Object Storage Classic

OpenStack Swift API w/ Java

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MediaType;

public class OciClassicSample {

  public static void main(String[] args) {
    Client client = ClientBuilder.newClient();

    client.target("https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject").request().header("X-Auth-Token", ...).header("X-Object-Meta-Sample-Key", "Sample Value").post(Entity.entity("", MediaType.WILDCARD_TYPE));

    client.close();
  }

}

OpenStack Swift API w/ Go

package ociclassicsample

import "gopkg.in/resty.v1"

func main() {
  resty.R().SetHeader("X-Auth-Token", ...).SetHeader("X-Object-Meta-Sample-Key", "Sample Value").Post("https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject")
}

OpenStack Swift API w/ Node.js

var https = require('https');

var req = https.request({ headers: { 'x-auth-token': ..., 'x-object-meta-sample-key': 'Sample Value' }, hostname: 'host', method: 'POST', path: '/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject' });

req.end();

OpenStack Swift API w/ Python

import requests

requests.post('https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject', headers = { 'X-Auth-Token': ..., 'X-Object-Meta-Sample-Key': 'Sample Value' })

OpenStack Swift API w/ Ruby

require 'rest-client'

RestClient.post 'https://Host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject', '', :x_auth_token => ..., :x_object_meta_sample_key => 'Sample Value'

OpenStack Swift CLI

1) Configure the CLI:

export ST_AUTH=https://host/auth/v1.0
export ST_USER=sampleservice-sampleidentitydomain:sampleuser
export ST_KEY=samplepassword

2) Run the following command:

swift post samplebucket sampleobject -m "Sample-Key:Sample Value

OpenStack Swift Client

from swiftclient.service import SwiftService

service = SwiftService({ 'auth': 'https://host/auth/v1.0', 'user': 'sampleService-sampleIdentityDomain:sampleUser', 'key': 'samplePassword' })

for res in service.post('sampleBucket', [ 'sampleObject' ], { 'meta': [ 'Sample-Key:Sample Value' ] }):
  print res

OCI Classic FTM API

import java.util.HashMap;
import java.util.Map;

import oracle.cloudstorage.ftm.FileTransferAuth;
import oracle.cloudstorage.ftm.FileTransferManager;

public class OciClassicSample {

  public static void main(String[] args) {
    FileTransferManager ftm = FileTransferManager.getDefaultFileTransferManager(new FileTransferAuth("sampleUser", "samplePassword", "sampleService", "https://host/", "sampleIdentityDomain"));

    Map<String, String> metadata = new HashMap<String, String>();

    metadata.put("Sample-Key", "Sample Value");

    ftm.setObjectMetadata("sampleBucket", "sampleObject", metadata, null);

    ftm.shutdown();
  }

}

OCI Classic FTM CLI

1) Run the following command:

java -jar ftmcli.jar set -U sampleuser -A https://host/ -S sampleservice -I sampleidentitydomain --save-auth-key -C "Sample-Key:Sample Value" samplebucket sampleobject

OCI Classic Java SDK

import oracle.cloud.storage.CloudStorage;
import oracle.cloud.storage.CloudStorageConfig;
import oracle.cloud.storage.CloudStorageFactory;

public class OciClassicSample {

  public static void main(String[] args) throws Exception {
    CloudStorage storage = CloudStorageFactory.getStorage(new CloudStorageConfig().setServiceName("sampleService-sampleIdentityDomain").setServiceUrl("https://host/").setUsername("sampleUser").setPassword("samplePassword"));

    storage.updateObjectMetadata("sampleBucket", "sampleObject", "Sample-Key", "Sample Value");
  }

}

AWS Python SDK

Not supported.

AWS Ruby SDK

Not supported.

AWS CLI

Not supported.

Terraform OCI Classic Provider

Not supported.

Terraform OpenStack Provider

1) Configure the provider:

export OS_SWAUTH=true
export OS_AUTH_URL=https://host/
export OS_USERNAME=sampleService-sampleIdentity:sampleUser
export OS_PASSWORD=samplePassword

2) Create the configuration:

resource "openstack_objectstorage_object_v1" "sampleobject" {
  name = "sampleobject"
  container_name = "samplebucket"
  content = "Simples Assim"
  metadata {
    Sample-Key = "Sample Value"
  }
}

3) Apply the change.

Terraform AWS Provider

Not supported.

s3cmd

Not supported.

How to Delete an Object in OCI Object Storage Classic

OpenStack Swift API w/ Java

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;

public class OciClassicSample {

  public static void main(String[] args) {
    Client client = ClientBuilder.newClient();

    client.target("https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject").request().header("X-Auth-Token", ...).delete();

    client.close();
  }

}

OpenStack Swift API w/ Go

package ociclassicsample

import "gopkg.in/resty.v1"

func main() {
  resty.R().SetHeader("X-Auth-Token", ...).Delete("https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject")
}

OpenStack Swift API w/ Node.js

var https = require('https');

var req = https.request({ headers: { 'x-auth-token': ... }, hostname: 'host', method: 'DELETE', path: '/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject' });

req.end();

OpenStack Swift API w/ Python

import requests

requests.delete('https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject', headers = { 'X-Auth-Token': ... })

OpenStack Swift API w/ Ruby

require 'rest-client'

RestClient.delete 'https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject', :x_auth_token => ...

OpenStack Swift CLI

1) Configure the CLI:

export ST_AUTH=https://host/auth/v1.0
export ST_USER=sampleservice-sampleidentitydomain:sampleuser
export ST_KEY=samplepassword

2) Run the following command:

swift delete samplebucket sampleobject

OpenStack Swift Client

from swiftclient.service import SwiftService

service = SwiftService({ 'auth': 'https://host/auth/v1.0', 'user': 'sampleService-sampleIdentityDomain:sampleUser', 'key': 'samplePassword' })

for res in service.delete('sampleBucket', [ 'sampleObject' ]):
  print res

OCI Classic FTM API

import oracle.cloudstorage.ftm.FileTransferAuth;
import oracle.cloudstorage.ftm.FileTransferManager;

public class OciClassicSample {

  public static void main(String[] args) {
    FileTransferManager ftm = FileTransferManager.getDefaultFileTransferManager(new FileTransferAuth("sampleUser", "samplePassword", "sampleService", "https://host/", "sampleIdentityDomain"));

    ftm.delete("sampleBucket", "sampleObject");

    ftm.shutdown();
  }

}

OCI Classic FTM CLI

1) Run the following command:

java -jar ftmcli.jar delete -U sampleuser -A https://host/ -S sampleservice -I sampleidentitydomain --save-auth-key samplebucket sampleobject

OCI Classic Java SDK

import oracle.cloud.storage.CloudStorage;
import oracle.cloud.storage.CloudStorageConfig;
import oracle.cloud.storage.CloudStorageFactory;

public class OciClassicSample {

  public static void main(String[] args) throws Exception {
    CloudStorage storage = CloudStorageFactory.getStorage(new CloudStorageConfig().setServiceName("sampleService-sampleIdentityDomain").setServiceUrl("https://host/").setUsername("sampleUser").setPassword("samplePassword"));

    storage.deleteObject("sampleBucket", "sampleObject");
  }

}

AWS Python SDK

import boto3

s3 = boto3.resource('s3', aws_access_key_id = 'sampleService-sampleIdentityDomain', aws_secret_access_key = 'sampleSecretAccessKey', endpoint_url = 'https://host/')

obj = s3.Object('sampleBucket', 'sampleObject')

obj.delete()

AWS Ruby SDK

require 'aws-sdk-s3'
 
s3 = Aws::S3::Resource.new access_key_id: 'sampleService-sampleIdentityDomain', secret_access_key: 'sampleSecretAccessKey', endpoint: 'https://host/v1/sampleService-sampleIdentityDomain', force_path_style: true, region: 'us-east-1' # region is ignored
 
bucket = s3.bucket 'sampleBucket'
 
obj = b.object 'sampleObject'
 
obj.delete

AWS CLI

1) Create the credentials file:

[default]
aws_access_key_id = sampleservice-sampleidentitydomain
aws_secret_access_key = samplesecretaccesskey

2) Run the following command:

aws s3api delete-object --bucket samplebucket --endpoint-url https://host/ --key sampleobject

Terraform OCI Classic Provider

1) Configure the provider:

export OPC_ENDPOINT=https://host/
export OPC_IDENTITY_DOMAIN=sampleidentitydomain
export OPC_USERNAME=sampleuser
export OPC_PASSWORD=samplepassword

2) If needed, import the object:

terraform import opc_storage_object.sampleobject sampleobject

3) Destroy the object.

Terraform OpenStack Provider

1) Configure the provider:

export OS_SWAUTH=true
export OS_AUTH_URL=https://host/
export OS_USERNAME=sampleservice-sampleidentitydomain:sampleuser
export OS_PASSWORD=samplepassword

2) If needed, import the object:

terraform import openstack_objectstorage_container_v1.sampleobject sampleobject

3) Destroy the object.

Terraform AWS Provider

1) Configure the provider:

provider "aws" {
  endpoints {
    s3 = "https://host/"
  }
  access_key = "sampleservice-sampleidentitydomain"
  secret_key = "samplesecretaccesskey"
  region = "us-east-1" # ignored
  skip_credentials_validation = true
  s3_force_path_style = true
}

2) If needed, import the bucket:

terraform import aws_s3_bucket_object.sampleobject sampleobject

3) Destroy the object.

s3cmd

1) Create the .s3cfg file:

[default]
host_base = host
host_bucket = host
access_key = sampleservice-sampleidentitydomain
secret_key = samplesecretaccesskey

2) Run the following command:

s3cmd del s3://samplebucket/sampleobject

How to Retrieve an Object in OCI Object Storage Classic

OpenStack Swift API w/ Java

import static java.lang.System.out;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;

public class OciClassicSample {

  public static void main(String[] args) {
    Client client = ClientBuilder.newClient();

    Response res = client.target("https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject").request().header("X-Auth-Token", ...).get();

    if (res.getStatus() == 200)
      out.println(res.readEntity(String.class));

    client.close();
  }

}

OpenStack Swift API w/ Go

package ociclassicsample

import "gopkg.in/resty.v1"

import "fmt"

func main() {
  res, _ := resty.R().SetHeader("X-Auth-Token", ...).Get("https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject")

  if res.StatusCode() == 200 {
    fmt.Printf("%v\n", res)
  }

}

OpenStack Swift API w/ Node.js

var https = require('https');

var req = https.request({ headers: { 'x-auth-token': ... }, hostname: 'host', method: 'GET', path: '/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject' }, (res) => {

  if (res.statusCode === 200) {
    var body = '';
 
    res.on('data', (chunk) => {
      body += chunk.toString();
    });
 
    res.on('end', () => {
      console.log(body);
    });
 
  }
 
});
 
req.end();

OpenStack Swift API w/ Python

import requests

res = requests.get('https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject', headers = { 'X-Auth-Token': ... })

if res.ok:
  print res.text

OpenStack Swift API w/ Ruby

require 'rest-client'

res = RestClient.get 'https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject', :x_auth_token => ...

if res.code == 200
  puts res.body
end

OpenStack Swift CLI

1) Configure the CLI:

export ST_AUTH=https://host/auth/v1.0
export ST_USER=sampleservice-sampleidentitydomain:sampleuser
export ST_KEY=samplepassword

2) Run the following command:

swift download samplebucket sampleobject

OpenStack Swift Client

from swiftclient.service import SwiftService

service = SwiftService({ 'auth': 'https://host/auth/v1.0', 'user': 'sampleService-sampleIdentityDomain:sampleUser', 'key': 'samplePassword' })

for res in service.download('sampleBucket', [ 'sampleObject' ], { 'out_file': sampleFile }):
  print res

OCI Classic FTM API

import oracle.cloudstorage.ftm.FileTransferAuth;
import oracle.cloudstorage.ftm.FileTransferManager;

public class OciClassicSample {

  public static void main(String[] args) {
    FileTransferManager ftm = FileTransferManager.getDefaultFileTransferManager(new FileTransferAuth("sampleUser", "samplePassword", "sampleService", "https://host/", "sampleIdentityDomain"));

    ftm.download(null, "sampleBucket", "sampleObject", sampleFile);

    ftm.shutdown();
  }

}

OCI Classic FTM CLI

1) Run the following command:

java -jar ftmcli.jar download -U sampleuser -A https://host/ -S sampleservice -I sampleidentitydomain -O samplefile --save-auth-key samplebucket sampleobject

OCI Classic Java SDK

import static java.lang.System.out;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import oracle.cloud.storage.CloudStorage;
import oracle.cloud.storage.CloudStorageConfig;
import oracle.cloud.storage.CloudStorageFactory;
import oracle.cloud.storage.model.StorageInputStream;

public class OciClassicSample {

  public static void main(String[] args) throws Exception {
    CloudStorage storage = CloudStorageFactory.getStorage(new CloudStorageConfig().setServiceName("sampleService-sampleIdentityDomain").setServiceUrl("https://host/").setUsername("sampleUser").setPassword("samplePassword"));

    StorageInputStream obj = storage.retrieveObject("sampleBucket", "sampleObject");

    BufferedReader in = new BufferedReader(new InputStreamReader(obj));

    in.lines().forEach(out::println);
  }

}

AWS Python SDK

import boto3

s3 = boto3.resource('s3', aws_access_key_id = 'sampleService-sampleIdentityDomain', aws_secret_access_key = 'sampleSecretAccessKey', endpoint_url = 'https://host/')

obj = s3.Object('sampleBucket', 'sampleObject')

obj.download_file(sampleFile)

AWS Ruby SDK

require 'aws-sdk-s3'

s3 = Aws::S3::Resource.new access_key_id: 'sampleService-sampleIdentityDomain', secret_access_key: 'sampleSecretAccessKey', endpoint: 'https://host/v1/sampleService-sampleIdentityDomain', force_path_style: true, region: 'us-east-1' # region is ignored

bucket = s3.bucket 'sampleBucket'

obj = b.object 'sampleObject'

obj.download_file('sampleFile')

AWS CLI

1) Create the credentials file:

[default]
aws_access_key_id = sampleservice-sampleidentitydomain
aws_secret_access_key = samplesecretaccesskey

2) Run the following command:

aws s3api get-object --bucket samplebucket --endpoint-url https://host/ --key sampleobject samplefile

Terraform OCI Classic Provider

N/A.

Terraform OpenStack Provider

N/A.

Terraform AWS Provider

N/A.

s3cmd

1) Create the .s3cfg file:

[default]
host_base = host
host_bucket = host
access_key = sampleservice-sampleidentitydomain
secret_key = samplesecretaccesskey

2) Run the following command:

s3cmd get s3://samplebucket/sampleobject

How to List Objects in OCI Object Storage Classic

OpenStack Swift API w/ Java

import static java.lang.System.out;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

public class OciClassicSample {

  public static void main(String[] args) {
    Client client = ClientBuilder.newClient();

    Response res = client.target("https://host/v1/sampleService-sampleIdentityDomain/sampleBucket").request(MediaType.WILDCARD_TYPE).header("X-Auth-Token", ...).get();

    if (res.getStatus() == 200)
      out.println(res.readEntity(String.class));

    client.close();
  }

}

OpenStack Swift API w/ Go

package ociclassicsample

import "gopkg.in/resty.v1"

import "fmt"

func main() {
  res, _ := resty.R().SetHeader("X-Auth-Token", ...).Get("https://host/v1/sampleService-sampleIdentityDomain/sampleBucket")

  if res.StatusCode() == 200 {
    fmt.Printf("%v\n", res)
  }

}

OpenStack Swift API w/ Node.js

var https = require('https');

var req = https.request({ headers: { 'x-auth-token': ... }, hostname: 'host', method: 'GET', path: '/v1/sampleService-sampleIdentityDomain/sampleBucket'}, (res) => {

  if (res.statusCode === 200) {
    var body = '';
 
    res.on('data', (chunk) => {
      body += chunk.toString();
    });
 
    res.on('end', () => {
      console.log(body);
    });
 
  }
 
});
 
req.end();

OpenStack Swift API w/ Python

import requests

res = requests.get('https://host/v1/sampleService-sampleIdentityDomain/sampleBucket', headers = { 'X-Auth-Token': ... })

if res.ok:
  print res.text

OpenStack Swift API w/ Ruby

require 'rest-client'

res = RestClient.get 'https://host/v1/sampleService-sampleIdentityDomain/sampleBucket', :x_auth_token => ...

if res.code == 200
  puts res.body
end

OpenStack Swift CLI

1) Configure the CLI:

export ST_AUTH=https://host/auth/v1.0
export ST_USER=sampleservice-sampleidentitydomain:sampleuser
export ST_KEY=samplepassword

2) Run the following command:

swift list samplebucket

OpenStack Swift Client

from swiftclient.service import SwiftService

service = SwiftService({ 'auth': 'https://host/auth/v1.0', 'user': 'sampleService-sampleIdentityDomain:sampleUser', 'key': 'samplePassword' })

for res in service.list('sampleBucket'):
  print res

OCI Classic FTM API

import static java.lang.System.out;

import oracle.cloudstorage.ftm.FileTransferAuth;
import oracle.cloudstorage.ftm.FileTransferManager;

public class OciClassicSample {

  public static void main(String[] args) {
    FileTransferManager ftm = FileTransferManager.getDefaultFileTransferManager(new FileTransferAuth("sampleUser", "samplePassword", "sampleService", "https://host/", "sampleIdentityDomain"));

    ftm.listObjects("sampleBucket").forEach(out::println);

    ftm.shutdown();
  }

}

OCI Classic FTM CLI

1) Run the following command:

java -jar ftmcli.jar list -U sampleuser -A https://host/ -S sampleservice -I sampleidentitydomain --save-auth-key samplebucket

OCI Classic Java SDK

import static java.lang.System.out;

import oracle.cloud.storage.CloudStorage;
import oracle.cloud.storage.CloudStorageConfig;
import oracle.cloud.storage.CloudStorageFactory;

public class OciClassicSample {

  public static void main(String[] args) throws Exception {
    CloudStorage storage = CloudStorageFactory.getStorage(new CloudStorageConfig().setServiceName("sampleService-sampleIdentityDomain").setServiceUrl("https://host/").setUsername("sampleUser").setPassword("samplePassword"));

    storage.listObjects("sampleBucket", null).forEach((o) -> out.println(o.getKey()));
  }

}

AWS Python SDK

import boto3
 
s3 = boto3.resource('s3', aws_access_key_id = 'sampleService-sampleIdentityDomain', aws_secret_access_key = 'sampleSecretAccessKey', endpoint_url = 'https://host/')

bucket = s3.Bucket('sampleBucket')

for o in bucket.objects.all():
  print o.name

AWS Ruby SDK

Not supported.

AWS CLI

1) Create the credentials file:

[default]
aws_access_key_id = sampleservice-sampleidentitydomain
aws_secret_access_key = samplesecretaccesskey

2) Run the following command:

aws s3api list-objects --bucket samplebucket --endpoint-url https://host/

Terraform

N/A.

s3cmd

1) Create the .s3cfg file:

[default]
host_base = host
host_bucket = host
access_key = sampleservice-sampleidentitydomain
secret_key = samplesecretaccesskey

2) Run the following command:

s3cmd ls s3://samplebucket

How to Create/Update an Object in OCI Object Storage Classic

OpenStack Swift API w/ Java

W/o Metadata

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;

public class OciClassicSample {

  public static void main(String[] args) {
    Client client = ClientBuilder.newClient();

    client.target("https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject").request().header("X-Auth-Token", ...).put(sampleFile);

    client.close();
  }

}

W/ Metadata

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;

public class OciClassicSample {

  public static void main(String[] args) {
    Client client = ClientBuilder.newClient();

    client.target("https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject").request().header("X-Auth-Token", ...).header("X-Object-Meta-Sample-Key", "Sample Value").put(sampleFile);

    client.close();
  }

}

OpenStack Swift API w/ Go

W/o Metadata

package ociclassicsample

import "gopkg.in/resty.v1"

func main() {
  resty.R().SetHeader("X-Auth-Token", ...).SetBody(sampleFile).Put("https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject")
}

W/ Metadata

package ociclassicsample

import "gopkg.in/resty.v1"

func main() {
  resty.R().SetHeader("X-Auth-Token", ...).SetHeader("X-Object-Meta-Sample-Key", "Sample Value").SetBody(sampleFile).Put("https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject")
}

OpenStack Swift API w/ Node.js

W/o Metadata

var https = require('https');

var req = https.request({ headers: { 'x-auth-token': ... }, hostname: 'host', method: 'PUT', path: '/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject' });

req.write(sampleFile);

req.end();

W/ Metadata

var https = require('https');

var req = https.request({ headers: { 'x-auth-token': ..., 'x-object-meta-sample-key': 'Sample Value' }, hostname: 'host', method: 'PUT', path: '/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject' });

req.write(sampleFile);

req.end();

OpenStack Swift API w/ Python

W/o Metadata

import requests

requests.put('https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject', headers = { 'X-Auth-Token': ... }, data = sampleFile)

W/ Metadata

import requests

requests.put('https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject', headers = { 'X-Auth-Token': ..., 'X-Object-Meta-Sample-Key': 'Sample Value' }, data = sampleFile)

OpenStack Swift API w/ Ruby

W/o Metadata

require 'rest-client'

RestClient.put 'https://Host/v1/SampleService-SampleIdentityDomain/SampleBucket/SampleObject', SampleFile, :x_auth_token => ...

W/o Metadata

require 'rest-client'

RestClient.put 'https://Host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject', SampleFile, :x_auth_token => ..., :x_container_meta_sample_key => 'Sample Value'

OpenStack Swift CLI

W/o Metadata

1) Configure the CLI:

export ST_AUTH=https://host/auth/v1.0
export ST_USER=sampleservice-sampleidentitydomain:sampleuser
export ST_KEY=samplepassword

2) Run the following command:

swift upload samplebucket samplefile --object-name sampleobject

W/ Metadata

1) Configure the CLI:

export ST_AUTH=https://host/auth/v1.0
export ST_USER=sampleservice-sampleidentitydomain:sampleuser
export ST_KEY=samplepassword

2) Run the following command:

swift upload samplebucket samplefile --object-name sampleobject -H "X-Object-Meta-Sample-Key:Sample Value"

OpenStack Swift Client

W/o Metadata

from swiftclient.service import SwiftService, SwiftUploadObject

service = SwiftService({ 'auth': 'https://host/auth/v1.0', 'user': 'sampleService-sampleIdentityDomain:sampleUser', 'key': 'samplePassword' })

for res in service.upload('sampleBucket', [ SwiftUploadObject(sampleFile, 'sampleObject') ]):
  print res

W/ Metadata

from swiftclient.service import SwiftService, SwiftUploadObject

service = SwiftService({ 'auth': 'https://host/auth/v1.0', 'user': 'sampleService-sampleIdentityDomain:sampleUser', 'key': 'samplePassword' })

for res in service.upload('sampleBucket', [ SwiftUploadObject(sampleFile, 'sampleObject') ], options = { 'header': [ 'X-Object-Meta-Sample-Key:Sample Value' ] } ):
  print res

OCI Classic FTM API

W/o Metadata

import java.io.File;

import oracle.cloudstorage.ftm.FileTransferAuth;
import oracle.cloudstorage.ftm.FileTransferManager;

public class OciClassicSample {

  public static void main(String[] args) {
    FileTransferManager ftm = FileTransferManager.getDefaultFileTransferManager(new FileTransferAuth("sampleUser", "samplePassword", "sampleService", "https://host/", "sampleIdentityDomain"));

    ftm.upload(null, "sampleBucket", "sampleObject", sampleFile);

    ftm.shutdown();
  }

}

W/ Metadata

Not supported.

OCI Classic FTM CLI

W/o Metadata

1) Run the following command:

java -jar ftmcli.jar upload -U sampleuser -A https://host/ -S sampleservice -I sampleidentitydomain --save-auth-key -N sampleobject samplebucket samplefile

W/ Metadata

Not supported.

OCI Classic Java SDK

W/o Metadata

import oracle.cloud.storage.CloudStorage;
import oracle.cloud.storage.CloudStorageConfig;
import oracle.cloud.storage.CloudStorageFactory;

public class OciClassicSample {

  public static void main(String[] args) throws Exception {
    CloudStorage storage = CloudStorageFactory.getStorage(new CloudStorageConfig().setServiceName("sampleService-sampleIdentityDomain").setServiceUrl("https://host/").setUsername("sampleUser").setPassword("samplePassword"));

    storage.storeObject("sampleBucket", "sampleObject", "*/*", sampleFile); // the contentType parameter will be optional in a future release
  }

}

W/ Metadata

import java.util.Map;
import java.util.HashMap;

import oracle.cloud.storage.CloudStorage;
import oracle.cloud.storage.CloudStorageConfig;
import oracle.cloud.storage.CloudStorageFactory;

public class OciClassicSample {

  public static void main(String[] args) throws Exception {
    CloudStorage storage = CloudStorageFactory.getStorage(new CloudStorageConfig().setServiceName("sampleService-sampleIdentityDomain").setServiceUrl("https://host/").setUsername("sampleUser").setPassword("samplePassword"));

    Map<String, String> metadata = new HashMap<String, String>();

    metadata.put("Sample-Key", "Sample Value");

    storage.storeObject("sampleBucket", "sampleObject", "*/*", metadata, sampleFile); // the contentType parameter will be optional in a future release
  }

}

AWS Python SDK

W/o Metadata

import boto3

from botocore.config import Config

s3 = boto3.resource('s3', aws_access_key_id = 'sampleService-sampleIdentityDomain', aws_secret_access_key = 'sampleSecretAccessKey', endpoint_url = 'https://host/v1/sampleService-sampleIdentityDomain', config = Config(s3 = { 'payload_signing_enabled': 'True' })) # unsigned payloads aren't supported

bucket = s3.Bucket('sampleBucket')

bucket.upload_file('sampleFile', 'sampleObject')

W/ Metadata

import boto3

from botocore.config import Config

s3 = boto3.resource('s3', aws_access_key_id = 'sampleService-sampleIdentityDomain', aws_secret_access_key = 'sampleSecretAccessKey', endpoint_url = 'https://host/v1/sampleService-sampleIdentityDomain', config = Config(s3 = { 'payload_signing_enabled': 'True' })) # unsigned payloads aren't supported

bucket = s3.Bucket('sampleBucket')

bucket.upload_file('sampleFile', 'sampleObject')

AWS Ruby SDK

Not supported.

AWS CLI

Not supported.

Terraform OCI Classic Provider

W/o Metadata

1) Configure the provider:

export OPC_ENDPOINT=https://host/
export OPC_IDENTITY_DOMAIN=sampleidentitydomain
export OPC_USERNAME=sampleuser
export OPC_PASSWORD=samplepassword

2) Create the configuration:

resource "opc_storage_object" "sampleobject" {
  name = "sampleobject"
  container = "samplebucket"
  content = samplefile
}

3) Apply the change.

W/ Metadata

Not supported.

Terraform OpenStack Provider

W/o Metadata

1) Configure the provider:

export OS_SWAUTH=true
export OS_AUTH_URL=https://host/
export OS_USERNAME=sampleservice-sampleidentitydomain:sampleuser
export OS_PASSWORD=samplepassword

2) Create the configuration:

resource "openstack_objectstorage_object_v1" "sampleobject" {
  name = "sampleobject"
  container_name = "samplebucket"
  content = samplefile
}

3) Apply the change.

W/ Metadata

1) Configure the provider:

export OS_SWAUTH=true
export OS_AUTH_URL=https://host/
export OS_USERNAME=sampleservice-sampleidentitydomain:sampleuser
export OS_PASSWORD=samplepassword

2) Create the configuration:

resource "openstack_objectstorage_object_v1" "sampleobject" {
  name = "sampleobject"
  container_name = "samplebucket"
  content = samplefile
  metadata {
    Sample-Key = "Sample Value"
  }
}

3) Apply the change.

Terraform AWS Provider

W/o Metadata

1) Configure the provider:

provider "aws" {
  endpoints {
    s3 = "https://host/"
  }
  access_key = "sampleservice-sampleidentitydomain"
  secret_key = "samplesecretaccesskey"
  region = "us-east-1" # ignored
  skip_credentials_validation = true
  s3_force_path_style = true
}

2) Create the configuration:

resource "aws_s3_bucket_object" "sampleobject" {
  key = "sampleobject"
  bucket = "samplebucket"
  source = "sampleFile"
}

3) Apply the change.

W/ Metadata

Not supported.

s3cmd

W/o Metadata

1) Create the .s3cfg file:

[default]
host_base = host
host_bucket = host
access_key = sampleservice-sampleidentitydomain
secret_key = samplesecretaccesskey

2) Run the following command:

s3cmd put samplefile s3://samplebucket

W/ Metadata

Not supported.

How to Delete Bucket Metadata in OCI Object Storage Classic

OpenStack Swift API w/ Java

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MediaType;

public class OciClassicSample {

  public static void main(String[] args) {
    Client client = ClientBuilder.newClient();

    client.target("https://host/v1/sampleService-sampleIdentityDomain/sampleBucket").request().header("X-Auth-Token",  ...).header("X-Remove-Container-Meta-Sample-Key", "").post(Entity.entity("", MediaType.WILDCARD_TYPE));

    client.close();
  }

}

OpenStack Swift API w/ Go

package ociclassicsample

import "gopkg.in/resty.v1"

func main() {
  resty.R().SetHeader("X-Auth-Token", ...).SetHeader("X-Remove-Container-Meta-Sample-Key", "").Post("https://host/v1/sampleService-sampleIdentityDomain/sampleBucket")
}

OpenStack Swift API w/ Node.js

var https = require('https');

var req = https.request({ headers: { 'x-auth-token': ..., 'x-remove-container-meta-sample-key': '' }, hostname: 'host', method: 'POST', path: '/v1/sampleService-sampleIdentityDomain/sampleBucket' });

req.end();

OpenStack Swift API w/ Python

import requests

requests.post('https://host/v1/sampleService-sampleIdentityDomain/sampleBucket', headers = { 'X-Auth-Token': ..., 'X-Remove-Container-Meta-Sample-Key': '' })

OpenStack Swift API w/ Ruby

require 'rest-client'

RestClient.post 'https://host/v1/sampleService-sampleIdentityDomain/sampleBucket', '', :x_auth_token => ..., :x_remove_container_meta_sample_key => ''

OpenStack Swift CLI

1) Configure the CLI:

export ST_AUTH=https://host/auth/v1.0
export ST_USER=sampleservice-sampleidentitydomain:sampleuser
export ST_KEY=samplepassword

2) Run the following command:

swift post sampleBucket -H "X-Remove-Container-Meta-Sample-Key:"

OpenStack Swift Client

from swiftclient.service import SwiftService

service = SwiftService({ 'auth': 'https://host/auth/v1.0', 'user': 'sampleService-sampleIdentityDomain:sampleUser', 'key': 'samplePassword' })

for res in service.post('sampleBucket', options = { 'header': [ 'X-Remove-Container-Meta-Sample-Key:' ] }):
  print res

OCI Classic FTM API

import java.util.HashMap;
import java.util.Map;

import oracle.cloudstorage.ftm.FileTransferAuth;
import oracle.cloudstorage.ftm.FileTransferManager;

public class OciClassicSample {

  public static void main(String[] args) {
    FileTransferManager ftm = FileTransferManager.getDefaultFileTransferManager(new FileTransferAuth("sampleUser", "samplePassword", "sampleService", "https://host/", "sampleIdentityDomain"));

    Map<String, String> metadata = new HashMap<String, String>();

    metadata.put("Sample-Key", "");

    ftm.setContainerMetadata("sampleBucket", metadata, null);

    ftm.shutdown();
  }

}

OCI Classic FTM CLI

Not supported.

OCI Classic Java SDK

import oracle.cloud.storage.CloudStorage;
import oracle.cloud.storage.CloudStorageConfig;
import oracle.cloud.storage.CloudStorageFactory;

public class OciClassicSample {

  public static void main(String[] args) throws Exception {
    CloudStorage storage = CloudStorageFactory.getStorage(new CloudStorageConfig().setServiceName("sampleService-sampleIdentityDomain").setServiceUrl("https://host/").setUsername("sampleUser").setPassword("samplePassword"));

    storage.deleteContainerMetadata("sampleBucket", "Sample-Key");
  }

}

AWS Python SDK

Not supported.

AWS Ruby SDK

Not supported.

AWS CLI

Not supported.

Terraform OCI Classic Provider

Not supported.

Terraform OpenStack Provider

1) Configure the provider:

export OS_SWAUTH=true
export OS_AUTH_URL=https://host/
export OS_USERNAME=sampleservice-sampleidentitydomain:sampleuser
export OS_PASSWORD=samplepassword

2) Remove the metadata values from the bucket configuration.

3) Apply the change.

Terraform AWS Provider

Not supported.

s3cmd

Not supported.