Class S3OutputFile

All Implemented Interfaces:
OutputFile, Closeable, AutoCloseable

public final class S3OutputFile extends AbstractOutputFile

An OutputFile that writes one S3 object, created by S3Source.outputFile(String, String).

The object is sent as a multipart upload, or in a single PUT when it is smaller than one part, and appears at its key only once AbstractOutputFile.close() succeeds. AbstractOutputFile.discard() aborts the upload. See S3Source.outputFile(String, String) for buffering, size limits and failure handling.

  • Method Details

    • doCreate

      protected void doCreate()
      Description copied from class: AbstractOutputFile
      Acquires the destination's resources, such as opening a file channel. Does nothing by default.
      Overrides:
      doCreate in class AbstractOutputFile
    • doWrite

      protected void doWrite(ByteBuffer data) throws IOException
      Description copied from class: AbstractOutputFile
      Appends the remaining bytes of data, consuming the buffer. Returning with bytes left in data makes write throw IllegalStateException, since position() would no longer match the file.
      Specified by:
      doWrite in class AbstractOutputFile
      Parameters:
      data - the bytes to append
      Throws:
      IOException - if the write fails
    • doClose

      protected void doClose() throws IOException
      Publishes the object: one PUT, or the remaining parts and the completion of the multipart upload. When it fails, doDiscard() aborts the upload.
      Overrides:
      doClose in class AbstractOutputFile
      Throws:
      IOException - if the file cannot be published; the file then ends discarded
    • doDiscard

      protected void doDiscard() throws IOException

      Waits for the part uploads in flight to end and aborts the multipart upload, if one was started.

      The wait and the abort run with the thread's interrupt status cleared, and the status restored afterwards, so that an interrupted writer still releases its parts.

      Overrides:
      doDiscard in class AbstractOutputFile
      Throws:
      IOException - if the resources cannot be released