Interface IUploadedFile

All Superinterfaces:
IUploadFile
All Known Implementing Classes:
UploadedFile

public interface IUploadedFile extends IUploadFile
A verified, completely received upload, as handed to IFileUploadListener.onFileCompleted(IUploadReservation,IUploadedFile).

The server process owns the staged file until the API user takes it with take() or removes it with delete(). A file left alone is still server-owned and is swept when its reservation or app session ends.

Author:
Christopher Mindus
  • Method Details

    • getVerifiedType

      String getVerifiedType()
      Gets the media type verified from the file's own bytes, when the sniffer knows the type.
      Returns:
      The verified type in lower case, or empty if the bytes were not sniffable and the declared type stands.
    • getSize

      long getSize()
      Gets the uncompressed size as measured during verification. It equals the declared size, because a mismatch fails verification.
      Returns:
      The size in bytes.
    • getCompressedSize

      long getCompressedSize()
      Gets the size of the staged file as stored, i.e. compressed if the transfer used gzip.
      Returns:
      The compressed size in bytes.
    • getInputStream

      InputStream getInputStream() throws IOException
      Opens the content, transparently decompressed: a caller reads the original bytes whatever compression the transfer used. Each call opens a new stream; the caller closes it.
      Returns:
      The stream of original bytes.
      Throws:
      IOException - For file errors.
      IllegalStateException - If the file has been deleted or taken.
    • getFile

      File getFile()
      Gets the staged file as stored on disk: the raw bytes as received, compressed if the transfer used gzip. The caller must neither delete nor move it; use take() for that.
      Returns:
      The raw file.
      Throws:
      IllegalStateException - If the file has been deleted or taken.
    • decompressTo

      long decompressTo(Path target) throws IOException
      Streams the decompressed content to a target file.
      Parameters:
      target - The target path; an existing file is replaced.
      Returns:
      The number of bytes written.
      Throws:
      IOException - For file errors.
      IllegalStateException - If the file has been deleted or taken.
    • take

      File take()
      Takes ownership of the raw staged file: the state becomes UploadState.CONSUMED, the quota is released, no sweep will ever touch the file again, and what happens next is the caller's business (move it, delete it, leave it). The sidecar stays until the reservation is swept.
      Returns:
      The raw file, compressed if the transfer used gzip.
      Throws:
      IllegalStateException - If already taken or deleted.
    • delete

      void delete()
      Deletes the staged file now: the state becomes UploadState.CONSUMED and the quota is released.
      Throws:
      IllegalStateException - If already taken or deleted.