public class BinariesServlet
extends javax.servlet.http.HttpServlet
<init-param> <param-name>contentDispositionContentTypes</param-name> <param-value> application/pdf, application/rtf, application/excel </param-value> </init-param>In the above init param configuration, you can also set glob style configurations such as '*/*' or 'application/*'. Also, you can configure the JCR property to get the file name from. The file name is used to send along in the HTTP response for content dispositioning. To configure this, set the "contentDispositionFilenameProperty" init param in the web.xml in which this servlet is defined. Example:
<init-param> <param-name>contentDispositionFilenameProperty</param-name> <param-value>demosite:filename</param-value> </init-param>The contentDispositionFilenameProperty is being encoded. By default, we try to do this user-agent-agnostic. This is preferrable when using caching reverse proxies in front of your application. In user-agent-agnostic mode, we try to convert filenames consisting non ascii chars to their base form, in other words, replace diacritics. However for for example a language like Chinese this won't work. Then, you might want to opt for the user-agent-specific mode. You then have to take care of your reverse proxies taking care of the user-agent. They thus should take the user-agent into account. Also see
#encodeContentDispositionFileName(HttpServletRequest, HttpServletResponse, String)
.
Changing the default user-agent-agnostic mode to user-agent-specific mode can be done by adding the init-param:
<init-param> <param-name>contentDispositionFilenameEncoding</param-name> <param-value>user-agent-specific</param-value> </init-param>You can also configure multiple JCR property names in the above init parameter by comma-separated value.
Modifier and Type | Field and Description |
---|---|
static String |
BASE_BINARIES_CONTENT_PATH_INIT_PARAM |
static String |
BINARY_DATA_PROP_NAME_INIT_PARAM |
static String |
BINARY_LAST_MODIFIED_PROP_NAME_INIT_PARAM |
static String |
BINARY_MIME_TYPE_PROP_NAME_INIT_PARAM |
static String |
BINARY_RESOURCE_NODE_TYPE_INIT_PARAM |
static String |
CONTENT_DISPOSITION_CONTENT_TYPES_INIT_PARAM |
static String |
CONTENT_DISPOSITION_FILENAME_ENCODING_INIT_PARAM
The init param indicating whether the fileName for the content disposition can be encoded 'user-agent-specific' or
'user-agent-agnostic', also see
#encodeContentDispositionFileName(HttpServletRequest, HttpServletResponse, String) |
static String |
CONTENT_DISPOSITION_FILENAME_PROPERTY_INIT_PARAM |
static String |
SET_CONTENT_LENGTH_HEADER_INIT_PARAM |
Constructor and Description |
---|
BinariesServlet() |
Modifier and Type | Method and Description |
---|---|
void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) |
protected void |
doInit() |
protected BinaryPage |
getBinaryPage(javax.servlet.http.HttpServletRequest request,
String resourcePath) |
protected boolean |
getBooleanInitParameter(String paramName,
boolean defaultValue) |
protected String |
getInitParameter(String paramName,
String defaultValue) |
protected long |
getLastModifiedFromResource(javax.servlet.http.HttpServletRequest request,
String resourcePath) |
protected long |
getLongInitParameter(String paramName,
long defaultValue) |
protected BinaryPage |
getPageFromCacheOrLoadPage(javax.servlet.http.HttpServletRequest request) |
protected InputStream |
getRepositoryResourceStream(javax.jcr.Session session,
BinaryPage page) |
protected BinaryPage |
getValidatedPageFromCache(javax.servlet.http.HttpServletRequest request,
BinaryPage page) |
void |
init(javax.servlet.ServletConfig config) |
protected void |
initBinaryPageValues(javax.jcr.Session session,
BinaryPage page) |
protected void |
storeResourceOnBinaryPage(BinaryPage page,
javax.jcr.Node resourceNode) |
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
public static final String SET_CONTENT_LENGTH_HEADER_INIT_PARAM
public static final String BASE_BINARIES_CONTENT_PATH_INIT_PARAM
public static final String CONTENT_DISPOSITION_CONTENT_TYPES_INIT_PARAM
public static final String CONTENT_DISPOSITION_FILENAME_PROPERTY_INIT_PARAM
public static final String CONTENT_DISPOSITION_FILENAME_ENCODING_INIT_PARAM
#encodeContentDispositionFileName(HttpServletRequest, HttpServletResponse, String)
public static final String BINARY_RESOURCE_NODE_TYPE_INIT_PARAM
public static final String BINARY_DATA_PROP_NAME_INIT_PARAM
public static final String BINARY_MIME_TYPE_PROP_NAME_INIT_PARAM
public static final String BINARY_LAST_MODIFIED_PROP_NAME_INIT_PARAM
public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException
init
in interface javax.servlet.Servlet
init
in class javax.servlet.GenericServlet
javax.servlet.ServletException
public void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
doGet
in class javax.servlet.http.HttpServlet
javax.servlet.ServletException
IOException
protected InputStream getRepositoryResourceStream(javax.jcr.Session session, BinaryPage page) throws javax.jcr.RepositoryException
session
- page
- BinaryPage.getResourcePath()
, or null
if
no binary could be found.javax.jcr.RepositoryException
protected BinaryPage getPageFromCacheOrLoadPage(javax.servlet.http.HttpServletRequest request)
protected BinaryPage getValidatedPageFromCache(javax.servlet.http.HttpServletRequest request, BinaryPage page)
protected long getLastModifiedFromResource(javax.servlet.http.HttpServletRequest request, String resourcePath)
protected BinaryPage getBinaryPage(javax.servlet.http.HttpServletRequest request, String resourcePath)
protected void initBinaryPageValues(javax.jcr.Session session, BinaryPage page) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
protected void storeResourceOnBinaryPage(BinaryPage page, javax.jcr.Node resourceNode)
protected void doInit()
protected boolean getBooleanInitParameter(String paramName, boolean defaultValue)
protected long getLongInitParameter(String paramName, long defaultValue)
Copyright © 2008-2013 Hippo B.V. (http://www.onehippo.com). All Rights Reserved.