Interface S3Client

All Superinterfaces:
net.solarnetwork.settings.SettingSpecifierProvider
All Known Implementing Classes:
SdkS3Client

public interface S3Client extends net.solarnetwork.settings.SettingSpecifierProvider
API for accessing S3.
Version:
2.0
Author:
matt
  • Method Details

    • isConfigured

      boolean isConfigured()
      Test if the client is fully configured.
      Returns:
      true if the client is configured
    • listObjects

      Set<S3ObjectReference> listObjects(String prefix) throws IOException
      List all available objects matching a prefix.
      Parameters:
      prefix - the prefix to match
      Returns:
      the matching objects, never null
      Throws:
      IOException - if an IO error occurs
    • getObjectAsString

      String getObjectAsString(String key) throws IOException
      Get the contents of a S3 object as a string.

      The S3 object is assumed to use the UTF-8 character set.

      Parameters:
      key - the key of the object to get
      Returns:
      the string, or null if not found
      Throws:
      IOException - if an IO error occurs
    • getObjectURL

      URL getObjectURL(String key)
      Get a URL for a S3 object.
      Parameters:
      key - the key
      Returns:
      the URL
    • getObject

      <P> S3Object getObject(String key, net.solarnetwork.service.ProgressListener<P> progressListener, P progressContext) throws IOException
      Get a S3 object.

      Note that the returned object's data may not be fetched from S3 until the InputStream returned by InputStreamSource.getInputStream() is read. That means the progressListener might not have any progress callbacks until that time as well.

      Type Parameters:
      P - the progress context type
      Parameters:
      key - the key of the object to get
      progressListener - an optional progress listener
      progressContext - an optional progress context
      Returns:
      the object, or null if not found
      Throws:
      IOException - if an IO error occurs
    • putObject

      <P> S3ObjectReference putObject(String key, InputStream in, S3ObjectMetadata objectMetadata, net.solarnetwork.service.ProgressListener<P> progressListener, P progressContext) throws IOException
      Put an object onto S3.
      Type Parameters:
      P - the progress context type
      Parameters:
      key - the key of the object to put
      in - the object contents
      objectMetadata - the object metadata
      progressListener - an optional progress listener
      progressContext - an optional progress context
      Returns:
      a reference to the put object
      Throws:
      IOException - if an IO error occurs
    • deleteObjects

      Set<String> deleteObjects(Iterable<String> keys) throws IOException
      Delete a set of keys from S3.
      Parameters:
      keys - the keys to delete
      Returns:
      the keys that were deleted
      Throws:
      IOException - if an IO error occurs