www.dextsolution.com
DEXTUPLOAD
NJ
menu toggleReference > devpia > dextuploadnj > support > spring > DEXTUploadNJStreamDownloadView

devpia.dextuploadnj.support.spring
Class DEXTUploadNJStreamDownloadView

Minimum version supported
1.0.0
Minimum support environment
JRE 1.6, Spring Framework
Description

The DEXTUploadNJStreamDownloadView is a concrete class of the DEXTUploadNJAbstractDownloadableView abstract class that supports response of file in Spring framework environment.

This is a view class to be used when downloading data on memory, not physical file.

@RequestMapping(value = "mapping URL", method = RequestMethod.GET)
public ModelAndView Method() throws IOException {
  
    // Prepares text data recorded in "0123456789".
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < 1000; i++) {
        sb.append("0123456789\r\n");
    }

    InputStream is = new ByteArrayInputStream(sb.toString().getBytes("UTF-8"));
      
    // Creates a DEXTUploadNJStreamDownloadView object to download with a stream object.
    DEXTUploadNJStreamDownloadView view = new DEXTUploadNJStreamDownloadView();
      
    // Sets the input stream. 
    view.setInputStream(is);
    view.setFilename("file name to download");
    view.setMime("text/plain");
    view.setCharsetName("UTF-8");
    // Sets the stream will be automatically closed as follows. (Since version 1.3.0) 
    view.setAutoClosingStream(true);
      
    return new ModelAndView(view);
}

When downloading is performed using the DEXTUploadNJStreamDownloadView object, the client cache is processed not to be used and functions such as partial download are not provided.

Constructor

DEXTUploadNJStreamDownloadView

  • Generate an object of the DEXTUploadNJStreamDownloadView class.

  • Signatures

    public DEXTUploadNJStreamDownloadView()
    public DEXTUploadNJStreamDownloadView(InputStream inputStream)
    public DEXTUploadNJStreamDownloadView(InputStream inputStream, String filename)
    public DEXTUploadNJStreamDownloadView(InputStream inputStream, String filename, String mime)
    public DEXTUploadNJStreamDownloadView(InputStream inputStream, String filename, String mime, boolean inline)
    public DEXTUploadNJStreamDownloadView(InputStream inputStream, String filename, String mime, boolean inline, int downloadStreamBufferSize)
    public DEXTUploadNJStreamDownloadView(InputStream inputStream, String filename, String mime, boolean inline, int downloadStreamBufferSize, boolean autoClosingStream)
    
    # Since version 2.7.0
    public DEXTUploadNJStreamDownloadView(InputStream inputStream, String filename, String mime, FileResponseContentDisposition contentDisposition, int downloadStreamBufferSize, boolean autoClosingStream)
  • Parameters

    Name Type Description
    inputStream java.io.InputStream the InputStream object providing data
    filename java.lang.String file name to download
    mime java.lang.String

    The MIME type of the file to be downloaded. If you do not know the target MIME type, you need to set the "application/octet-stream".

    inline boolean

    If the value of this parameters is set to true, the file will not be downloaded and may be opened directly from the browser.

    downloadStreamBufferSize (Supported from version 1.2.2) int

    When downloading, the size of the buffer to be recorded at once in the response stream.

    The default is 32768 bytes.

    autoClosingStream (Supported from version 1.3.0) boolean

    After downloading is completed, sets whether to close the InputStream object.

    The default value is false.

    contentDisposition (Supported since version 2.7.0) devpia.dextuploadnj.FileResponseContentDisposition

    The method value of processing file content in browsers

Methods

getInputStream

  • Returns a java.io.InputStream object providing data.

  • Signatures

    public InputStream getInputStream()
  • Returns

    an java.io.InputStream object providing data

setInputStream

  • Set a java.io.InputStream object providing data.

  • Signatures

    public void setInputStream(InputStream inputStream)
  • Parameters

    Name Type Description
    inputStream java.io.InputStream an InputStream object providing data

isAutoClosingStream (Supported from version 1.3.0)

  • When downloading data, it will automatically return whether or not to close the InputStream object.

  • Signatures

    public boolean isAutoClosingStream()
  • Returns

    true, false

setAutoClosingStream (Supported from version 1.3.0)

  • When downloading data, automatically set whether to close InputStream object.

  • Signatures

    public void setAutoClosingStream(boolean autoClosingStream)
  • Parameters

    Name Type Description
    autoClosingStream boolean If the value of this parameter is true, write the data to the response buffer and then close the InputStream object.

doRenderImpl

See the doRenderImpl method of the DEXTUploadNJAbstractDownloadableView class.

getFilename

See the getFilename method of the DEXTUploadNJAbstractDownloadableView class.

setFilename

See the setFilename method of the DEXTUploadNJAbstractDownloadableView class.

getMime

See the getMime method of the DEXTUploadNJAbstractDownloadableView class.

setMime

See the setMime method of the DEXTUploadNJAbstractDownloadableView class.

isInline

See the isInline method of the DEXTUploadNJAbstractDownloadableView class.

setInline

See the setInline method of the DEXTUploadNJAbstractDownloadableView class.

getCharsetName

See the getCharsetName method of the DEXTUploadNJAbstractDownloadableView class.

setCharsetName

See the setCharsetName method of the DEXTUploadNJAbstractDownloadableView class.

getDownloadStreamBufferSize

See the getDownloadStreamBufferSize method of the DEXTUploadNJAbstractDownloadableView class.

setDownloadStreamBufferSize

See the setDownloadStreamBufferSize method of the DEXTUploadNJAbstractDownloadableView class.

getContentDisposition

See the getContentDisposition method of the DEXTUploadNJAbstractDownloadableView class.

setContentDisposition

See the setContentDisposition method of the DEXTUploadNJAbstractDownloadableView class