Package org.nuxeo.ecm.core.io.download
Class DownloadHelper
- java.lang.Object
-
- org.nuxeo.ecm.core.io.download.DownloadHelper
-
public class DownloadHelper extends Object
Helper class related to the download service.- Since:
- 7.3
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringgetContentTypeHeader(Blob blob)Gets the Content-Type header for the given blob, per RFC 2616.static StringgetRFC2231ContentDisposition(javax.servlet.http.HttpServletRequest request, String filename)Generates aContent-Dispositionstring based on the servlet request for a given filename.static StringgetRFC2231ContentDisposition(javax.servlet.http.HttpServletRequest request, String filename, Boolean inline)Generates aContent-Dispositionstring for a given filename.static voidhandleClientDisconnect(IOException e)Re-throws the passed exception except if it corresponds to a client disconnect, for which logging doesn't bring us anything.static booleanisClientAbortError(Throwable t)static voidlogClientAbort(Throwable t)static ByteRangeparseRange(String range, long length)Parses a byte range.
-
-
-
Field Detail
-
INLINE
public static final String INLINE
- See Also:
- Constant Field Values
-
-
Method Detail
-
parseRange
public static ByteRange parseRange(String range, long length)
Parses a byte range.- Parameters:
range- the byte range as a stringlength- the file length- Returns:
- the byte range, or
nullif it couldn't be parsed.
-
getRFC2231ContentDisposition
public static String getRFC2231ContentDisposition(javax.servlet.http.HttpServletRequest request, String filename)
Generates aContent-Dispositionstring based on the servlet request for a given filename.The value follows RFC2231.
- Parameters:
request- the http servlet requestfilename- the filename- Returns:
- a full string to set as value of a
Content-Dispositionheader
-
getRFC2231ContentDisposition
public static String getRFC2231ContentDisposition(javax.servlet.http.HttpServletRequest request, String filename, Boolean inline)
Generates aContent-Dispositionstring for a given filename.The value follows RFC2231.
- Parameters:
request- the http servlet requestfilename- the filenameinline- how to set the content disposition;TRUEforinline,FALSEforattachment, ornullto detect frominlinerequest parameter or attribute- Returns:
- a full string to set as value of a
Content-Dispositionheader - Since:
- 7.10
-
getContentTypeHeader
public static String getContentTypeHeader(Blob blob)
Gets the Content-Type header for the given blob, per RFC 2616.For example
application/pdfortext/plain; charset=ISO-8859-1.- Parameters:
blob- the blob- Returns:
- the header, or
nullif the blob has no content type information - Since:
- 11.1
-
isClientAbortError
public static boolean isClientAbortError(Throwable t)
-
logClientAbort
public static void logClientAbort(Throwable t)
-
handleClientDisconnect
public static void handleClientDisconnect(IOException e) throws IOException
Re-throws the passed exception except if it corresponds to a client disconnect, for which logging doesn't bring us anything.- Parameters:
e- the original exception- Throws:
IOException- if this is not a client disconnect
-
-