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 String
getContentTypeHeader(Blob blob)
Gets the Content-Type header for the given blob, per RFC 2616.static String
getRFC2231ContentDisposition(javax.servlet.http.HttpServletRequest request, String filename)
Generates aContent-Disposition
string based on the servlet request for a given filename.static String
getRFC2231ContentDisposition(javax.servlet.http.HttpServletRequest request, String filename, Boolean inline)
Generates aContent-Disposition
string for a given filename.static void
handleClientDisconnect(IOException e)
Re-throws the passed exception except if it corresponds to a client disconnect, for which logging doesn't bring us anything.static boolean
isClientAbortError(Throwable t)
static void
logClientAbort(Throwable t)
static ByteRange
parseRange(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
null
if it couldn't be parsed.
-
getRFC2231ContentDisposition
public static String getRFC2231ContentDisposition(javax.servlet.http.HttpServletRequest request, String filename)
Generates aContent-Disposition
string 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-Disposition
header
-
getRFC2231ContentDisposition
public static String getRFC2231ContentDisposition(javax.servlet.http.HttpServletRequest request, String filename, Boolean inline)
Generates aContent-Disposition
string for a given filename.The value follows RFC2231.
- Parameters:
request
- the http servlet requestfilename
- the filenameinline
- how to set the content disposition;TRUE
forinline
,FALSE
forattachment
, ornull
to detect frominline
request parameter or attribute- Returns:
- a full string to set as value of a
Content-Disposition
header - 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/pdf
ortext/plain; charset=ISO-8859-1
.- Parameters:
blob
- the blob- Returns:
- the header, or
null
if 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
-
-