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

devpia.dextuploadnj.support.spring
Class DEXTUploadNJFileDownloadView

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

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

It is a view class to be used when downloading data of a physical file.

@RequestMapping(value = "mapping URL", method = RequestMethod.GET)
public ModelAndView Method(...) {
    
  // Create a DEXTUploadNJFileDownloadView object to download a file. 
  DEXTUploadNJFileDownloadView view = new DEXTUploadNJFileDownloadView();
    
  view.setFile(new File("path of the file"));
  view.setFilename("file name to download");
  view.setMime("text/plain");
  view.setCharsetName("UTF-8");
    
  // Starts downloading.
  return new ModelAndView(view);
}
Constructor

DEXTUploadNJFileDownloadView

  • Generate an object of the DEXTUploadNJFileDownloadView class.

  • Signatures

    public DEXTUploadNJFileDownloadView()
    public DEXTUploadNJFileDownloadView(File file)
    public DEXTUploadNJFileDownloadView(File file, String filename)
    public DEXTUploadNJFileDownloadView(File file, String filename, String mime)
    public DEXTUploadNJFileDownloadView(File file, String filename, String mime, boolean inline)
    public DEXTUploadNJFileDownloadView(File file, String filename, String mime, boolean inline, boolean useClientCache)
    public DEXTUploadNJFileDownloadView(File file, String filename, String mime, boolean inline, boolean useClientCache, boolean removeAfterDownloading)
    public DEXTUploadNJFileDownloadView(File file, String filename, String mime, boolean inline, boolean useClientCache, boolean removeAfterDownloading, int downloadStreamBufferSize)
    public DEXTUploadNJFileDownloadView(File file, String filename, String mime, boolean inline, boolean useClientCache, boolean removeAfterDownloading, int downloadStreamBufferSize, long expiringTime)
    
    # Since verison 2.7.0
    public DEXTUploadNJFileDownloadView(File file, String filename, String mime, FileResponseContentDisposition contentDisposition, boolean useClientCache, boolean removeAfterDownloading, int downloadStreamBufferSize, long expiringTime)
    
    # Since version 2.14.0
    public DEXTUploadNJFileDownloadView(File file, String filename, String mime, FileResponseContentDisposition contentDisposition, boolean useClientCache, boolean removeAfterDownloading, int downloadStreamBufferSize, long expiringTime, boolean useTomcatSendFile)
  • Parameters

    Name Type Description
    file java.io.File the file object to download
    filename java.lang.String the 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.

    useClientCache boolean

    whether to use the client's cache policy

    removeAfterDownloading (Supported since version 1.2.0) boolean

    If this is true, it will delete the target file after the download process is completed.

    downloadStreamBufferSize (Supported since version 1.2.2) int

    The size of the buffer to be written at once in the response stream. The default is 32768 bytes.

    expiringTime (Supported since version 2.2.0) long

    The time value to determine the expiration date of the cache. The default is 31536000 seconds.

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

    The method value of processing file content in browsers

    useTomcatSendFile (2.14.0 or later) boolean Whether to use Tomcat sendFile
Methods

getFile

  • Returns the target java.io.File object to be downloaded.

  • Signatures

    public File getFile()
  • Returns

    the target java.io.File object to be downloaded

setFile

  • Sets the target java.io.File object to be downloaded.

  • Signatures

    public void setFile(File file)
  • Parameters

    Name Type Description
    file java.io.File the file object to be downloaded

isAllowingWeakRange

  • Returns whether or not to execute Partial Content download with only the Range request header.

    (Partial Content downloading is to return a part of data to response data.)

  • Signatures

    public boolean isAllowingWeakRange()
  • Returns

    true, false

setAllowingWeakRange

  • Sets whether to execute Partial Content download with only the Range request header.

    (Partial Content downloading is to return a part of data to response data.)

  • Signatures

    public void setAllowingWeakRange(boolean allowingWeakRange)
  • Parameters

    Name Type Description
    allowingWeakRange boolean If true, processes with Range header only, if false, checks if-Range header.

isUseClientCache

  • Returns whether or not to use the client's cache policy.

  • Signatures

    public boolean isUseClientCache()
  • Returns

    If true, it is using the cache policy, if false, otherwise.

setUseClientCache

  • Sets whether or not to use the client's cache policy.

    Even if you set it to true, you are not using cache policy when downloading from the stream not a file.

  • Signatures

    public void setUseClientCache(boolean useClientCache)
  • Parameters

    Name Type Description
    useClientCache boolean If true, it is using the cache policy, if false, otherwise.

isRemoveAfterDownloading (Supported since version 1.2.0)

  • After downloading the file, returns whether or not to delete the target file.

  • Signatures

    public boolean isRemoveAfterDownloading()
  • Returns

    true, false

setRemoveAfterDownloading (Supported since version 1.2.0)

  • After downloading the file, sets whether or not to delete the target file.

    The file deletion function operates only when downloading a physical file on disk, and file deletion can fail if another system preempted the target file.

  • Signatures

    public void setRemoveAfterDownloading(boolean removeAfterDownloading)
  • Parameters

    Name Type Description
    removeAfterDownloading boolean true, false

getExpiringTime (Supported since version 2.2.0)

  • Returns the time value required to set the cache expiration response header.

  • Signatures

    public long getExpiringTime()
  • Returns

    the time value in seconds required to set the cache expiration response header

setExpiringTime (Supported since version 2.2.0)

  • Sets the time value requrited to set the cache expiration response header.

  • Signatures

    public void setExpiringTime(long time)
  • Parameters

    Name Type Description
    time long the time value in seconds

getUseTomcatSendFile (Supported since version 1.2.0)

  • Returns whether to use Tomcat sendFile for file downloads.

  • Signatures

    public boolean getUseTomcatSendFile()
  • Returns

    true or false, the default value is false.

setUseTomcatSendFile (Supported since version 1.2.0)

  • Sets whether to use Tomcat sendFile for file downloads.

    (Caution) This setting cannot be used when HTTP compression is enabled or when the response data is controlled through a servlet filter. If an error occurs, set this value to false to use the default download method.

  • Signatures

    public void setUseTomcatSendFile(boolean useTomatSendFile)
  • Parameters

    Name Type Description
    useTomatSendFile boolean true to use sendFile, otherwise false

doRenderImpl

See the doRenderImpl method of the DEXTUploadNJAbstractDownloadableView abstract class.

getFilename

See the getFilename method of the DEXTUploadNJAbstractDownloadableView abstract class.

setFilename

See the setFilename method of the DEXTUploadNJAbstractDownloadableView abstract class.

getMime

See the getMime method of the DEXTUploadNJAbstractDownloadableView abstract class.

setMime

See the setMime method of the DEXTUploadNJAbstractDownloadableView abstract class.

isInline

See the isInline method of the DEXTUploadNJAbstractDownloadableView abstract class.

setInline

See the setInline method of the DEXTUploadNJAbstractDownloadableView abstract class.

getCharsetName

See the getCharsetName method of the DEXTUploadNJAbstractDownloadableView abstract class.

setCharsetName

See the setCharsetName method of the DEXTUploadNJAbstractDownloadableView abstract class.

getDownloadStreamBufferSize

See the getDownloadStreamBufferSize method of the DEXTUploadNJAbstractDownloadableView abstract class.

setDownloadStreamBufferSize

See the setDownloadStreamBufferSize method of the DEXTUploadNJAbstractDownloadableView abstract class.

getContentDisposition

See the getContentDisposition method of the DEXTUploadNJAbstractDownloadableView class.

setContentDisposition

See the setContentDisposition method of the DEXTUploadNJAbstractDownloadableView class