OCI Object Storage Tools

Advertisements

OCI Object Storage Classic Tool Coverage Chart

User Story Console OpenStack Swift API OpenStack Swift CLI OpenStack Swift Client FTM API FTM CLI Java SDK Terraform OCI Classic Provider Terraform OpenStack Provider
Generate Authentication Token Y Y Y Y N N N N N
Create/Update Bucket Y Y Y Y Y N Y Y Y
List Buckets Y Y Y Y Y Y Y N N
Delete Bucket Y Y Y Y Y Y Y Y Y
Create/Update Bucket Metadata Y Y Y Y Y Y Y N Y
Retrieve Bucket Metadata Y Y Y Y Y Y Y N N
Delete Bucket Metadata Y Y Y Y Y N Y N Y
Create/Update Object Y Y Y Y Y Y Y Y Y
List Objects Y Y Y Y Y Y Y N N
Retrieve Object Y Y Y Y Y Y Y N N
Delete Object Y Y Y Y Y Y Y Y Y
Create/Update Object Metadata Y Y Y Y Y Y Y N Y
Retrieve Object Metadata Y Y Y Y Y Y Y N N
Delete Object Metadata Y Y Y Y Y N Y N Y

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 final class OciClassicSample {

  public static void main(final String[] args) {
    final 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

const https = require('https');

const 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=password

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

FTM API

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

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

public final class OciClassicSample {

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

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

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

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

    ftm.shutdown();
  }

}

FTM CLI

Not supported.

Java SDK

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

public final class OciClassicSample {

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

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

}

Terraform OCI Classic Provider

N/A.

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.

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 final class OciClassicSample {

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

    final 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

const https = require('https');

const 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=password

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

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 final class OciClassicSample {

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

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

    final ObjectMetadata metadata = obj.getObjectMetadata();

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

    ftm.shutdown();
  }

}

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

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 final class OciClassicSample {

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

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

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

}

Terraform OCI Classic Provider

N/A.

Terraform OpenStack Provider

N/A.

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 final class OciClassicSample {

  public static void main(final String[] args) {
    final 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

const https = require('https');

const 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-sampleIdentity:sampleUser
export ST_KEY=password

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-sampleIdentity:sampleUser', 'key': 'samplePassword' })

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

FTM API

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

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

public final class OciClassicSample {

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

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

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

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

    ftm.shutdown();
  }

}

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

Java SDK

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

public final class OciClassicSample {

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

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

}

Terraform OCI Classic Provider

N/A.

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_container_v1" "sample_bucket" {
  name = "sample_bucket"
}

resource "openstack_objectstorage_object_v1" "sample_object" {
  name = "sampleObject"
  container_name = "${openstack_objectstorage_container_v1.sample_bucket.name}"
  content = "Simples Assim"
  metadata {
    Sample-Key = "Sample Value" # new/updated value
  }
}

3) Apply the change.

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 final class OciClassicSample {

  public static void main(final String[] args) {
    final 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

const https = require('https');

const 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=password

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

FTM API

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

public final class OciClassicSample {

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

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

    ftm.shutdown();
  }

}

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

Java SDK

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

public final class OciClassicSample {

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

    storage.deleteObject("sampleBucket", "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.sample_object 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.sample_object sampleObject

3) Destroy the object.

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 final class OciClassicSample {

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

    final 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

const https = require('https');

const 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=password

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

FTM API

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

public final class OciClassicSample {

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

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

    ftm.shutdown();
  }

}

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

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 final class OciClassicSample {

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

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

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

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

}

Terraform OCI Classic Provider

N/A.

Terraform OpenStack Provider

N/A.

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 final class OciClassicSample {

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

    final 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

const https = require('https');

const 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=password

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

FTM API

import static java.lang.System.out;

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

public final class OciClassicSample {

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

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

    ftm.shutdown();
  }

}

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

Java SDK

import static java.lang.System.out;

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

public final class OciClassicSample {

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

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

}

Terraform OCI Classic Provider

N/A.

Terraform OpenStack Provider

N/A.

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;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MediaType;

public final class OciClassicSample {

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

    client.target("https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject").request().header("X-Auth-Token", ...).put(Entity.entity("Simples Assim", MediaType.WILDCARD_TYPE));

    client.close();
  }

}

W/ Metadata

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 final class OciClassicSample {

  public static void main(final String[] args) {
    final 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(Entity.entity("Simples Assim", MediaType.WILDCARD_TYPE));

    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("Simples Assim").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("Simples Assim").Put("https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject")
}

OpenStack Swift API w/ Node.js

W/o Metadata

const https = require('https');

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

req.write('Simples Assim');

req.end();

W/ Metadata

const https = require('https');

const 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('Simples Assim');

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 = 'Simples Assim')

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 = 'Simples Assim')

OpenStack Swift API w/ Ruby

W/o Metadata

require 'rest-client'

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

W/o Metadata

require 'rest-client'

RestClient.put 'https://host/v1/sampleService-sampleIdentityDomain/sampleBucket/sampleObject', 'Simples Assim', :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=password

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=password

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

FTM API

W/o Metadata

import java.io.File;

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

public final class OciClassicSample {

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

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

    ftm.shutdown();
  }

}

W/ Metadata

Not supported.

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.

Java SDK

W/o Metadata

import java.io.ByteArrayInputStream;

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

public final class OciClassicSample {

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

    storage.storeObject("sampleBucket", "sampleObject", "*/*", new ByteArrayInputStream("Simples Assim".getBytes())); // the contentType parameter will be optional in a future release
  }

}

W/ Metadata

import java.io.ByteArrayInputStream;
import java.util.Map;
import java.util.HashMap;

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

public final class OciClassicSample {

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

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

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

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

}

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_container" "sample_bucket" {
  name = "sampleBucket"
}

resource "opc_storage_object" "sample_object" {
  name = "sampleObject"
  container = "${opc_storage_container.sample_bucket.name}"
  content = "Simples Assim"
}

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_container_v1" "sample_bucket" {
  name = "sample_bucket"
}

resource "openstack_objectstorage_object_v1" "sample_object" {
  name = "sampleObject"
  container_name = "${openstack_objectstorage_container_v1.sample_bucket.name}"
  content = "Simples Assim"
}

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_container_v1" "sample_bucket" {
  name = "sample_bucket"
}

resource "openstack_objectstorage_object_v1" "sample_object" {
  name = "sampleObject"
  container_name = "${openstack_objectstorage_container_v1.sample_bucket.name}"
  content = "Simples Assim"
  metadata {
    Sample-Key = "Sample Value"
  }
}

3) Apply the change.