Class NettyStreamingFileUpload

java.lang.Object
io.micronaut.http.server.netty.multipart.NettyStreamingFileUpload
All Implemented Interfaces:
FileUpload, StreamingFileUpload, Publisher<PartData>

@Internal public final class NettyStreamingFileUpload extends Object implements StreamingFileUpload
An implementation of the StreamingFileUpload interface for Netty.
Since:
1.0
Author:
Graeme Rocher
  • Method Details

    • getContentType

      public Optional<MediaType> getContentType()
      Description copied from interface: FileUpload
      Gets the content type of this part.
      Specified by:
      getContentType in interface FileUpload
      Returns:
      The content type of this part.
    • getName

      public String getName()
      Description copied from interface: FileUpload
      Gets the name of this part.
      Specified by:
      getName in interface FileUpload
      Returns:
      The name of this part
    • getFilename

      public String getFilename()
      Description copied from interface: FileUpload
      Gets the name of this part.
      Specified by:
      getFilename in interface FileUpload
      Returns:
      The name of this part
    • getSize

      public long getSize()
      Description copied from interface: FileUpload
      Returns the size of the part.
      Specified by:
      getSize in interface FileUpload
      Returns:
      The size of this part, in bytes.
    • getDefinedSize

      public long getDefinedSize()
      Description copied from interface: FileUpload
      Returns the defined content length of the part.
      Specified by:
      getDefinedSize in interface FileUpload
      Returns:
      The content length of this part, in bytes.
    • isComplete

      public boolean isComplete()
      Description copied from interface: FileUpload
      Returns whether the FileUpload has been fully uploaded or is in a partial state.
      Specified by:
      isComplete in interface FileUpload
      Returns:
      True if the part is fully uploaded
    • transferTo

      public Publisher<Boolean> transferTo(String location)
      Description copied from interface: StreamingFileUpload

      A convenience method to write this uploaded item to disk.

      This method will return a no-op Publisher if called multiple times for the same location

      Specified by:
      transferTo in interface StreamingFileUpload
      Parameters:
      location - the name of the file to which the stream will be written. The file is created relative to the location as specified in the MultipartConfiguration
      Returns:
      A Publisher that outputs whether the transfer was successful
    • transferTo

      public Publisher<Boolean> transferTo(File destination)
      Description copied from interface: StreamingFileUpload

      A convenience method to write this uploaded item to disk.

      This method will return a no-op Publisher if called multiple times for the same location

      Specified by:
      transferTo in interface StreamingFileUpload
      Parameters:
      destination - the destination of the file to which the stream will be written.
      Returns:
      A Publisher that outputs whether the transfer was successful
    • transferTo

      public Publisher<Boolean> transferTo(OutputStream outputStream)
      Description copied from interface: StreamingFileUpload

      A convenience method to write this uploaded item the provided output stream.

      Specified by:
      transferTo in interface StreamingFileUpload
      Parameters:
      outputStream - the destination to which the stream will be written.
      Returns:
      A Publisher that outputs whether the transfer was successful
    • delete

      public Publisher<Boolean> delete()
      Description copied from interface: StreamingFileUpload
      Deletes the underlying storage for a file item, including deleting any associated temporary disk file.
      Specified by:
      delete in interface StreamingFileUpload
      Returns:
      A Publisher that outputs whether to delete was successful
    • asInputStream

      public InputStream asInputStream()
      Description copied from interface: StreamingFileUpload
      Create an InputStream that reads this file. The returned stream must be closed after use. The stream may block when data isn't yet available.
      Specified by:
      asInputStream in interface StreamingFileUpload
      Returns:
      An InputStream that reads this file's contents
    • createTemp

      protected File createTemp(String location)
      Parameters:
      location - The location for the temp file
      Returns:
      The temporal file
    • subscribe

      public void subscribe(Subscriber<? super PartData> s)
      Specified by:
      subscribe in interface Publisher<PartData>
    • discard

      public void discard()
      Description copied from interface: FileUpload
      Discards the contents of the file. This must be called if the file will not be read and has not already been read. Failure to either read or discard the file will result in memory leaks!
      Specified by:
      discard in interface FileUpload