Class StorageImpl

java.lang.Object
com.oracle.cloud.spring.storage.StorageImpl
All Implemented Interfaces:
Storage

public class StorageImpl extends Object implements Storage
Default implementation for Storage
  • Constructor Details

  • Method Details

    • download

      public OracleStorageResource download(String bucketName, String key, String version)
      Downloads a specific object from OCI Object Storage.
      Specified by:
      download in interface Storage
      Parameters:
      bucketName - OCI storage bucket name.
      key - Object name
      version - Version of the object
      Returns:
      OracleStorageResource
    • download

      public OracleStorageResource download(String bucketName, String key)
      Downloads the latest version of a specific object from OCI Object Storage.
      Specified by:
      download in interface Storage
      Parameters:
      bucketName - OCI storage bucket name.
      key - Object name
      Returns:
      OracleStorageResource
    • upload

      public OracleStorageResource upload(String bucketName, String key, InputStream inputStream, @Nullable StorageObjectMetadata objectMetadata) throws IOException
      Uploads a new object (using InputStream) to OCI Object Storage.
      Specified by:
      upload in interface Storage
      Parameters:
      bucketName - OCI storage bucket name.
      key - Object name
      inputStream - Object data with InputStream data type.
      objectMetadata - StorageObjectMetadata
      Returns:
      OracleStorageResource
      Throws:
      IOException
    • store

      public OracleStorageResource store(String bucketName, String key, Object object) throws IOException
      Uploads a Java POJO as a JSON object.
      Specified by:
      store in interface Storage
      Parameters:
      bucketName - OCI storage bucket name.
      key - Object name
      object - POJO object to be stored as json.
      Returns:
      OracleStorageResource
      Throws:
      IOException
    • read

      public <T> T read(String bucketName, String key, Class<T> clazz)
      Reads a JSON file stored on Object storage and converts it to a Java POJO.
      Specified by:
      read in interface Storage
      Parameters:
      bucketName - OCI storage bucket name.
      key - Object name
      clazz - Type of the Java POJO.
      Returns:
      Object instnace of clazz.
    • getClient

      public com.oracle.bmc.objectstorage.ObjectStorageClient getClient()
      Directs an instance of OCI Java SDK Storage Client.
      Specified by:
      getClient in interface Storage
      Returns:
      ObjectStorageClient
    • createBucket

      public com.oracle.bmc.objectstorage.responses.CreateBucketResponse createBucket(String bucketName)
      Creates a new bucket with the specified bucket name.
      Specified by:
      createBucket in interface Storage
      Parameters:
      bucketName - OCI storage bucket name.
      Returns:
      CreateBucketResponse
    • createBucket

      public com.oracle.bmc.objectstorage.responses.CreateBucketResponse createBucket(String bucketName, String compartmentId)
      Creates a new bucket with the specified bucket name on a specific OCI compartment.
      Specified by:
      createBucket in interface Storage
      Parameters:
      bucketName - OCI storage bucket name.
      compartmentId - OCI compartment OCID.
      Returns:
      CreateBucketResponse
    • deleteBucket

      public void deleteBucket(String bucketName)
      Deletes a storage bucket.
      Specified by:
      deleteBucket in interface Storage
      Parameters:
      bucketName - OCI storage bucket name.
    • deleteObject

      public void deleteObject(String bucketName, String key)
      Deletes a storage object based on bucket name and object key.
      Specified by:
      deleteObject in interface Storage
      Parameters:
      bucketName - OCI storage bucket name.
      key - Object name/key.s
    • getNamespaceName

      public String getNamespaceName()
      Gets the current OCI storage namespace.
      Specified by:
      getNamespaceName in interface Storage
      Returns:
      name of the namespace.
    • resolveContentType

      public String resolveContentType(String objectName, StorageObjectMetadata metadata)