Class StreamedFile

    • Constructor Summary

      Constructors 
      Constructor Description
      StreamedFile​(java.io.InputStream inputStream, io.micronaut.http.MediaType mediaType)  
      StreamedFile​(java.io.InputStream inputStream, io.micronaut.http.MediaType mediaType, long lastModified)  
      StreamedFile​(java.io.InputStream inputStream, io.micronaut.http.MediaType mediaType, long lastModified, long contentLength)  
      StreamedFile​(java.net.URL url)
      Immediately opens a connection to the given URL to retrieve data about the connection, including the input stream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      StreamedFile attach​(java.lang.String attachmentName)
      Sets the file to be downloaded as an attachment.
      java.io.InputStream getInputStream()  
      long getLastModified()  
      long getLength()  
      io.micronaut.http.MediaType getMediaType()  
      void process​(io.micronaut.http.MutableHttpResponse<?> response)
      Modify the response before it is written to the client.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StreamedFile

        public StreamedFile​(java.io.InputStream inputStream,
                            io.micronaut.http.MediaType mediaType)
        Parameters:
        inputStream - The input stream
        mediaType - The media type of the content
      • StreamedFile

        public StreamedFile​(java.io.InputStream inputStream,
                            io.micronaut.http.MediaType mediaType,
                            long lastModified)
        Parameters:
        inputStream - The input stream
        mediaType - The media type of the content
        lastModified - The last modified date
      • StreamedFile

        public StreamedFile​(java.io.InputStream inputStream,
                            io.micronaut.http.MediaType mediaType,
                            long lastModified,
                            long contentLength)
        Parameters:
        inputStream - The input stream
        mediaType - The media type of the content
        lastModified - The last modified date
        contentLength - the content length
      • StreamedFile

        public StreamedFile​(java.net.URL url)
        Immediately opens a connection to the given URL to retrieve data about the connection, including the input stream.
        Parameters:
        url - The URL to resource
    • Method Detail

      • getInputStream

        public java.io.InputStream getInputStream()
        Returns:
        The stream used to retrieve data for the file
      • attach

        public StreamedFile attach​(java.lang.String attachmentName)
        Sets the file to be downloaded as an attachment. The name is set in the Content-Disposition header.
        Parameters:
        attachmentName - The attachment name.
        Returns:
        The same StreamedFile instance
      • process

        public void process​(io.micronaut.http.MutableHttpResponse<?> response)
        Description copied from interface: CustomizableResponseType
        Modify the response before it is written to the client.
        Specified by:
        process in interface CustomizableResponseType
        Parameters:
        response - The response to modify