How to Delete Object Metadata in OCI Object Storage Classic

API w/ Java

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

public final class ObjectStorageSample {

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

    client.target("https://host/v1/sampleService-sampleIdentityDomain/sample_bucket/sample_object").request().header("X-Auth-Token", ...).header("X-Remove-Object-Meta-Sample-Key", "").post(Entity.text(""));

    client.close();
  }

}

API w/ Node.js

API w/ Python

import requests

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

API w/ Ruby

require 'rest-client'

RestClient.post 'https://host/v1/sampleService-sampleIdentityDomain/sample_bucket/sample_object', :x_auth_token => ..., :x_remove_object_meta_sample_key => nil

FTM API

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

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

public final class ObjectStorageSample {

  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", null);

    ftm.setObjectMetadata("sample_bucket", "sample_object", 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 ObjectStorageSample {

  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("sample_bucket", "sample_object", "Sample-Key"); // omit the "X-Object-Meta" prefix
   }

}
Advertisements

How to Retrieve Object Metadata in OCI Object Storage Classic

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 ObjectStorageSample {

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

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

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

    client.close();
  }

}

API w/ Node.js

API w/ Python

import requests

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

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

API w/ Ruby

require 'rest-client'

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

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

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 ObjectStorageSample {

  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("sample_bucket", "sample_object");

    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 sample_bucket sample_object

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 ObjectStorageSample {

  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("sample_bucket", "sample_object");

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

}

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

API w/ Java

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

public final class ObjectStorageSample {

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

    client.target("https://host/v1/sampleService-sampleIdentityDomain/sample_bucket/sample_object").request().header("X-Auth-Token", ...).header("X-Object-Meta-Sample-Key", "Sample Value").post(Entity.text(""));

    client.close();
  }

}

API w/ Node.js

API w/ Python

import requests

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

API w/ Ruby

require 'rest-client'

RestClient.post 'https://host/v1/sampleService-sampleIdentityDomain/sample_bucket/sample_object', '', :x_auth_token => ..., :x_object_meta_sample_key => 'Sample Value'

FTM API

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

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

public final class ObjectStorageSample {

  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("sample_bucket", "sample_object", 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" sample_bucket sample_object

Java SDK

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

public final class ObjectStorageSample {

  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("sample_bucket", "sample_object", "Sample-Key", "Sample Value");
  }

}

How to Delete an Object in OCI Object Storage Classic

API w/ Java

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

public final class ObjectStorageSample {

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

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

    client.close();
  }

}

API w/ Node.js

API w/ Python

import requests

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

API w/ Ruby

require 'rest-client'

RestClient.delete'https://host/v1/sampleService-sampleIdentitYDomain/sample_bucket/sample_object', :x_auth_token => ...

FTM API

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

public final class ObjectStorageSample {

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

    ftm.delete("sample_bucket", "sample_object");

    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 sample_bucket sample_object

Java SDK

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

public final class ObjectStorageSample {

  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.deleteContainer("sample_bucket", "sample_object");
  }

}

How to Retrieve an Object in OCI Object Storage Classic

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 ObjectStorageSample {

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

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

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

    client.close();
  }

}

API w/ Node.js

API w/ Python

import requests

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

if res.ok:
  print(res.text)

API w/ Ruby

require 'rest-client'

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

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

FTM API

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

public final class ObjectStorageSample {

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

    ftm.download(null, "sample_bucket", "sample_object", new File("sample_file"));

    ftm.shutdown();
  }

}

FTM CLI

1) Run the following command:

java -jar ftmcli.jar download -U sampleUser -A https://host/ -S sampleService -I sampleIdentityDomain -O sample_file --save-auth-key sample_bucket sample_object

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 ObjectStorageSample {

  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("sample_bucket", "sample_object");

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

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

}

How to List Objects in OCI Object Storage Classic

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 ObjectStorageSample {

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

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

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

    client.close();
  }

}

API w/ Node.js

API w/ Python

import requests

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

if res.ok:
  print(res.text)

API w/ Ruby

require 'rest-client'

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

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

FTM API

import static java.lang.System.out;

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

public final class ObjectStorageSample {

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

    ftm.listObjects("sample_bucket").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 sample_bucket

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 ObjectStorageSample {

  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("sample_bucket", null).forEach((o) -> out.println(o.getKey()));
  }

}

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

API w/ Java

W/o Metadata

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

public final class ObjectStorageSample {

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

    client.target("https://host/v1/sampleService-sampleIdentityDomain/sample_bucket/sample_object").request().header("X-Auth-Token", ...).put(Entity.text("Simples Assim"));

    client.close();
  }

}

W/ Metadata

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

public final class ObjectStorageSample {

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

    client.target("https://host/v1/sampleService-sampleIdentityDomain/sample_bucket/sample_object").request().header("X-Auth-Token", ...).header("X-Object-Meta-Sample-Key", "Sample Value").put(Entity.text("Simples Assim"));

    client.close();
  }

}

API w/ Node.js

W/o Metadata

W/ Metadata

API w/ Python

W/o Metadata

import requests

requests.put('https://host/v1/sampleService-sampleIdentityDomain/sample_bucket/sample_object', headers = { 'X-Auth-Token': ... }, data = 'Simples Assim')

W/ Metadata

import requests

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

API w/ Ruby

W/o Metadata

require 'rest-client'

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

W/o Metadata

require 'rest-client'

RestClient.put 'https://host/v1/sampleService-sampleIdentityDomain/sample_bucket/sample_object', 'Simples Assim', :x_auth_token => ..., :x_container_meta_sample_key => 'Sample Value'

FTM API

W/o Metadata

import java.io.File;

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

public final class ObjectStorageSample {

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

    ftm.upload(null, "sample_bucket", "sample_object", new File("sample_file"));

    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 sample_object sample_bucket sample_file

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 ObjectStorageSample {

  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("sample_bucket", "sample_object", "text/plain", new ByteArrayInputStream("Simples Assim".getBytes()));
  }

}

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 ObjectStorageSample {

  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("sample_bucket", "sample_object", "text/plain", metadata, new ByteArrayInputStream("Simples Assim".getBytes()));
  }

}

How to Delete Bucket Metadata in OCI Object Storage Classic

API w/ Java

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

public final class ObjectStorageSample {

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

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

    client.close();
  }

}

API w/ Node.js

API w/ Python

import requests

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

API w/ Ruby

require 'rest-client'

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

FTM API

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

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

public final class ObjectStorageSample {

  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", null);

    ftm.setContainerMetadata("sample_bucket", 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 ObjectStorageSample {

  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.deleteContainerMetadata("sample_bucket", "Sample-Key");
  }

}

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

API w/ Java

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

public final class ObjectStorageSample {

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

    client.target("https://host/v1/sampleService-sampleIdentityDomain/sample_bucket").request().header("X-Auth-Token",  ...).header("X-Container-Meta-Sample-Key", "Sample Value").post(Entity.text(""));

    client.close();
  }

}

API w/ Node.js

API w/ Python

import requests

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

API w/ Ruby

require 'rest-client'

RestClient.post 'https://host/v1/sampleService-sampleIdentityDomain/sample_bucket', '', :x_auth_token => ..., :x_container_meta_sample_key => 'Sample Value'

FTM API

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

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

public final class ObjectStorageSample {

  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.updateContainerMetadata("sample_bucket", 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" sample_bucket

Java SDK

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

public final class ObjectStorageSample {

  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.updateContainerMetadata("sample_bucket", "Sample-Key", "Sample Value");
  }

}

How to Retrieve Bucket Metadata in OCI Object Storage Classic

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 ObjectStorageSample {

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

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

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

    client.close();
  }

}

API w/ Node.js

API w/ Python

import requests

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

if res.ok:

  for k, v in res.headers.items():
    print(k + " = " + v)

API w/ Ruby

require 'rest-client'

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

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

FTM API

import static java.lang.System.out;

import oracle.cloudstorage.ftm.FileTransferAuth;
import oracle.cloudstorage.ftm.FileTransferManager;
import oracle.cloudstorage.ftm.model.CloudContainer;
import oracle.cloudstorage.ftm.model.ContainerMetadata;

public final class ObjectStorageSample {

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

    final CloudContainer bucket = ftm.getContainer("sample_bucket");

    final ContainerMetadata metadata = bucket.getMetadata();

    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 sample_bucket

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.Container;

public final class ObjectStorageSample {

  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 Container bucket = storage.describeContainer("sample_bucket");

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

}