java.lang.Object
com.google.cloud.spring.storage.integration.GcsSession
All Implemented Interfaces:
Closeable, AutoCloseable, org.springframework.integration.file.remote.session.Session<com.google.cloud.storage.BlobInfo>

public class GcsSession extends Object implements org.springframework.integration.file.remote.session.Session<com.google.cloud.storage.BlobInfo>
A session implementation for Google Cloud Storage.
  • Constructor Details

    • GcsSession

      public GcsSession(com.google.cloud.storage.Storage gcs)
  • Method Details

    • remove

      public boolean remove(String path) throws IOException
      Specified by:
      remove in interface org.springframework.integration.file.remote.session.Session<com.google.cloud.storage.BlobInfo>
      Throws:
      IOException
    • list

      public com.google.cloud.storage.BlobInfo[] list(String bucket) throws IOException
      Only supports listing buckets, not folders.
      Specified by:
      list in interface org.springframework.integration.file.remote.session.Session<com.google.cloud.storage.BlobInfo>
      Parameters:
      bucket - The name of the bucket.
      Returns:
      The BlobInfo of all objects in the bucket.
      Throws:
      IOException - Thrown if there an issue communicating with GCS.
    • read

      public void read(String source, OutputStream outputStream) throws IOException
      Specified by:
      read in interface org.springframework.integration.file.remote.session.Session<com.google.cloud.storage.BlobInfo>
      Throws:
      IOException
    • write

      public void write(InputStream inputStream, String destination) throws IOException
      Specified by:
      write in interface org.springframework.integration.file.remote.session.Session<com.google.cloud.storage.BlobInfo>
      Throws:
      IOException
    • append

      public void append(InputStream inputStream, String destination) throws IOException
      Specified by:
      append in interface org.springframework.integration.file.remote.session.Session<com.google.cloud.storage.BlobInfo>
      Throws:
      IOException
    • mkdir

      public boolean mkdir(String directory) throws IOException
      Specified by:
      mkdir in interface org.springframework.integration.file.remote.session.Session<com.google.cloud.storage.BlobInfo>
      Throws:
      IOException
    • rmdir

      public boolean rmdir(String directory) throws IOException
      Specified by:
      rmdir in interface org.springframework.integration.file.remote.session.Session<com.google.cloud.storage.BlobInfo>
      Throws:
      IOException
    • rename

      public void rename(String pathFrom, String pathTo) throws IOException
      Specified by:
      rename in interface org.springframework.integration.file.remote.session.Session<com.google.cloud.storage.BlobInfo>
      Throws:
      IOException
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface org.springframework.integration.file.remote.session.Session<com.google.cloud.storage.BlobInfo>
    • isOpen

      public boolean isOpen()
      Specified by:
      isOpen in interface org.springframework.integration.file.remote.session.Session<com.google.cloud.storage.BlobInfo>
    • exists

      public boolean exists(String path) throws IOException
      Specified by:
      exists in interface org.springframework.integration.file.remote.session.Session<com.google.cloud.storage.BlobInfo>
      Throws:
      IOException
    • listNames

      public String[] listNames(String path) throws IOException
      Specified by:
      listNames in interface org.springframework.integration.file.remote.session.Session<com.google.cloud.storage.BlobInfo>
      Throws:
      IOException
    • readRaw

      public InputStream readRaw(String source) throws IOException
      Specified by:
      readRaw in interface org.springframework.integration.file.remote.session.Session<com.google.cloud.storage.BlobInfo>
      Throws:
      IOException
    • finalizeRaw

      public boolean finalizeRaw() throws IOException
      Specified by:
      finalizeRaw in interface org.springframework.integration.file.remote.session.Session<com.google.cloud.storage.BlobInfo>
      Throws:
      IOException
    • getClientInstance

      public Object getClientInstance()
      Specified by:
      getClientInstance in interface org.springframework.integration.file.remote.session.Session<com.google.cloud.storage.BlobInfo>
    • getHostPort

      public String getHostPort()
      Specified by:
      getHostPort in interface org.springframework.integration.file.remote.session.Session<com.google.cloud.storage.BlobInfo>