Package com.jcabi.s3

Interface Ocket

All Superinterfaces:
Comparable<Ocket>
All Known Implementing Classes:
CdOcket, FkOcket, Ocket.Empty, Ocket.Text, ReOcket

public interface Ocket extends Comparable<Ocket>
Amazon S3 object abstraction.

You get an instance of this interface from Bucket, for example:

 Region region = new Region.Simple(key, secret);
 Bucket bucket = region.bucket("my.example.com");
 Ocket ocket = bucket.ocket("src/main/README.txt");

In order to read and write plain text content in Unicode we recommend to use Ocket.Text decorator:

 Ocket.Text ocket = new Ocket.Smart(
   bucket.ocket("src/main/README.txt")
 );
 ocket.write("hello, world!", "text/plain");
 
Since:
0.1
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final class 
    Ocket with no content at all.
    static final class 
    Unicode text S3 object with supplementary functions.
  • Method Summary

    Modifier and Type
    Method
    Description
    Get bucket we're in.
    boolean
    Check whether this S3 object exists.
    key()
    Get object key.
    software.amazon.awssdk.services.s3.model.HeadObjectResponse
    Object metadata.
    void
    Read content.
    void
    write(InputStream input, software.amazon.awssdk.services.s3.model.HeadObjectResponse meta)
    Write new content to the object.

    Methods inherited from interface java.lang.Comparable

    compareTo
  • Method Details

    • bucket

      Bucket bucket()
      Get bucket we're in.
      Returns:
      Bucket
    • key

      String key()
      Get object key.
      Returns:
      Key
    • meta

      software.amazon.awssdk.services.s3.model.HeadObjectResponse meta() throws IOException
      Object metadata.

      Throws OcketNotFoundException if this object doesn't exist in S3 bucket.

      Returns:
      Metadata
      Throws:
      IOException - If fails
    • exists

      boolean exists() throws IOException
      Check whether this S3 object exists.
      Returns:
      TRUE if it exists in S3, FALSE otherwise
      Throws:
      IOException - If fails
      Since:
      0.4
    • read

      void read(OutputStream output) throws IOException
      Read content.

      Throws OcketNotFoundException if this object doesn't exist in S3 bucket.

      Parameters:
      output - Where to write
      Throws:
      IOException - If fails
    • write

      void write(InputStream input, software.amazon.awssdk.services.s3.model.HeadObjectResponse meta) throws IOException
      Write new content to the object.
      Parameters:
      input - Where to get content
      meta - Metadata to save
      Throws:
      IOException - If fails