Package org.silverpeas.core.web.http
Class FileResponse
- java.lang.Object
-
- org.silverpeas.core.web.http.FileResponse
-
- Direct Known Subclasses:
RestFileResponse
,ServletFileResponse
public abstract class FileResponse extends Object
Centralizing the code which permits to send a file, and if necessary or asked to send it partially.- Author:
- Yohann Chastagnier
-
-
Field Summary
Fields Modifier and Type Field Description static String
DOWNLOAD_CONTEXT_PARAM
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static String
encodeAttachmentFilenameAsUtf8(String filename)
Encodes the content disposition with attachment filename as UTF8.static String
encodeInlineFilenameAsUtf8(String filename)
Encodes the content disposition with inline filename as UTF8.FileResponse
forceCharacterEncoding(String forcedCharacterEncoding)
Forces the character encoding of the response.FileResponse
forceFileId(String fileId)
Forces the file identifier.
If not forced, the absolute path of the file into Base64 is computed.FileResponse
forceFileName(String fileName)
Forces the file name into the response.
If not forced, the file name is computed from the file itself.
Even if a file name has been forced, if the request contains into headers a valuatedforceFileName
parameter, the file name from the request is taken into account.FileResponse
forceMimeType(String mimeType)
Forces the mime type of the response.
If not forced, the mime type is computed from the file itself.
Even if a mime type has been forced, if the request contains into headers a valuatedforceMimeType
parameter, the mime type from the request is taken into account.static RestFileResponse
fromRest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Initializing the file response context.static ServletFileResponse
fromServlet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Initializing the file response context.FileResponse
noCache()
Sets into response that no cache MUST be handled.
-
-
-
Field Detail
-
DOWNLOAD_CONTEXT_PARAM
public static final String DOWNLOAD_CONTEXT_PARAM
- See Also:
- Constant Field Values
-
-
Method Detail
-
encodeInlineFilenameAsUtf8
public static String encodeInlineFilenameAsUtf8(String filename)
Encodes the content disposition with inline filename as UTF8.- Parameters:
filename
- the filename to encode.- Returns:
- the encoded
-
encodeAttachmentFilenameAsUtf8
public static String encodeAttachmentFilenameAsUtf8(String filename)
Encodes the content disposition with attachment filename as UTF8.- Parameters:
filename
- the filename to encode.- Returns:
- the encoded
-
fromRest
public static RestFileResponse fromRest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Initializing the file response context.- Parameters:
request
- the current request.response
- the current response.- Returns:
- the initialized file response.
-
fromServlet
public static ServletFileResponse fromServlet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Initializing the file response context.- Parameters:
request
- the current request.response
- the current response.- Returns:
- the initialized file response.
-
forceFileId
public FileResponse forceFileId(String fileId)
Forces the file identifier.
If not forced, the absolute path of the file into Base64 is computed.- Parameters:
fileId
- the file identifier.- Returns:
- itself.
-
forceFileName
public FileResponse forceFileName(String fileName)
Forces the file name into the response.
If not forced, the file name is computed from the file itself.
Even if a file name has been forced, if the request contains into headers a valuatedforceFileName
parameter, the file name from the request is taken into account.- Parameters:
fileName
- the file name to set.- Returns:
- itself.
-
forceMimeType
public FileResponse forceMimeType(String mimeType)
Forces the mime type of the response.
If not forced, the mime type is computed from the file itself.
Even if a mime type has been forced, if the request contains into headers a valuatedforceMimeType
parameter, the mime type from the request is taken into account.- Parameters:
mimeType
- the mime type to set.- Returns:
- itself.
-
forceCharacterEncoding
public FileResponse forceCharacterEncoding(String forcedCharacterEncoding)
Forces the character encoding of the response.- Parameters:
forcedCharacterEncoding
- the character encoding to set.- Returns:
- itself.
-
noCache
public FileResponse noCache()
Sets into response that no cache MUST be handled.- Returns:
- itself.
-
-