Module org.apache.wicket.core
Class MultipartServletWebRequestImpl
java.lang.Object
org.apache.wicket.request.Request
org.apache.wicket.request.http.WebRequest
org.apache.wicket.protocol.http.servlet.ServletWebRequest
org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest
org.apache.wicket.protocol.http.servlet.MultipartServletWebRequestImpl
- All Implemented Interfaces:
IMultipartWebRequest
Servlet specific WebRequest subclass for multipart content uploads.
- Author:
- Jonathan Locke, Eelco Hillenius, Cameron Braid, Ate Douma, Igor Vaynberg (ivaynberg)
-
Field Summary
Fields inherited from class org.apache.wicket.request.http.WebRequest
HEADER_AJAX, HEADER_AJAX_BASE_URL, HEADER_ORIGIN, HEADER_REFERER, PARAM_AJAX, PARAM_AJAX_BASE_URL, PARAM_AJAX_REQUEST_ANTI_CACHE
-
Constructor Summary
ConstructorDescriptionMultipartServletWebRequestImpl
(jakarta.servlet.http.HttpServletRequest request, String filterPrefix, Bytes maxSize, String upload) Constructor.MultipartServletWebRequestImpl
(jakarta.servlet.http.HttpServletRequest request, String filterPrefix, Bytes maxSize, String upload, org.apache.commons.fileupload2.core.FileItemFactory factory) Constructor -
Method Summary
Modifier and TypeMethodDescriptionstatic void
clearUploadInfo
(jakarta.servlet.http.HttpServletRequest req, String upload) Clears theUploadInfo
object from session if one exists.protected Map<String,
List<StringValue>> List<org.apache.commons.fileupload2.core.FileItem>
Gets the file that was uploaded using the given field name.getFiles()
static UploadInfo
getUploadInfo
(jakarta.servlet.http.HttpServletRequest req, String upload) RetrievesUploadInfo
from session, null if not found.protected org.apache.commons.fileupload2.core.AbstractFileUpload
newFileUpload
(String encoding) Factory method for creating new instances of AbstractFileUploadnewMultipartWebRequest
(Bytes maxSize, String upload) Creates multipart web request from this request.newMultipartWebRequest
(Bytes maxSize, String upload, org.apache.commons.fileupload2.core.FileItemFactory factory) Creates multipart web request from this request.protected void
Upload completed callbackprotected void
onUploadStarted
(int totalBytes) Upload start callbackprotected void
onUploadUpdate
(int bytesUploaded, int total) Upload status update callbackvoid
Parses the multipart body of the request.static void
setUploadInfo
(jakarta.servlet.http.HttpServletRequest req, String upload, UploadInfo uploadInfo) Sets theUploadInfo
object into session.protected boolean
Subclasses that want to receive upload notifications should return true.Methods inherited from class org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest
cloneWithUrl, getFileCountMax, getFileMaxSize, getMaxSize, setFileCountMax, setFileMaxSize, setMaxSize
Methods inherited from class org.apache.wicket.protocol.http.servlet.ServletWebRequest
getCharset, getClientUrl, getContainerRequest, getContextPath, getCookies, getDateHeader, getFilterPath, getFilterPrefix, getHeader, getHeaders, getLocale, getPostParameters, getPrefixToContextPath, getUrl, shouldPreserveClientUrl
Methods inherited from class org.apache.wicket.request.http.WebRequest
getCookie, getIfModifiedSinceHeader, isAjax
Methods inherited from class org.apache.wicket.request.Request
getOriginalUrl, getQueryParameters, getRequestParameters
-
Constructor Details
-
MultipartServletWebRequestImpl
public MultipartServletWebRequestImpl(jakarta.servlet.http.HttpServletRequest request, String filterPrefix, Bytes maxSize, String upload) throws org.apache.commons.fileupload2.core.FileUploadException Constructor. This constructor will useDiskFileItemFactory
to store uploads.- Parameters:
request
- the servlet requestfilterPrefix
- prefix to wicket filter mappingmaxSize
- the maximum size allowed for this requestupload
- upload identifier forUploadInfo
- Throws:
org.apache.commons.fileupload2.core.FileUploadException
- Thrown if something goes wrong with upload
-
MultipartServletWebRequestImpl
public MultipartServletWebRequestImpl(jakarta.servlet.http.HttpServletRequest request, String filterPrefix, Bytes maxSize, String upload, org.apache.commons.fileupload2.core.FileItemFactory factory) throws org.apache.commons.fileupload2.core.FileUploadException Constructor- Parameters:
request
- the servlet requestfilterPrefix
- prefix to wicket filter mappingmaxSize
- the maximum size allowed for this requestupload
- upload identifier forUploadInfo
factory
-DiskFileItemFactory
to use when creating file items used to represent uploaded files- Throws:
org.apache.commons.fileupload2.core.FileUploadException
- Thrown if something goes wrong with upload
-
-
Method Details
-
parseFileParts
Description copied from class:MultipartServletWebRequest
Parses the multipart body of the request.- Specified by:
parseFileParts
in classMultipartServletWebRequest
- Throws:
org.apache.commons.fileupload2.core.FileUploadException
-
newFileUpload
Factory method for creating new instances of AbstractFileUpload- Parameters:
encoding
- The encoding to use while reading the data- Returns:
- A new instance of AbstractFileUpload
-
getFiles
- Returns:
- Returns the files.
-
getFile
Gets the file that was uploaded using the given field name.- Parameters:
fieldName
- the field name that was used for the upload- Returns:
- the upload with the given field name
-
generatePostParameters
- Overrides:
generatePostParameters
in classServletWebRequest
-
wantUploadProgressUpdates
Subclasses that want to receive upload notifications should return true. By default, it takes the value fromApplicationSettings.isUploadProgressUpdatesEnabled()
.- Returns:
- true if upload status update event should be invoked
-
onUploadStarted
Upload start callback- Parameters:
totalBytes
-
-
onUploadUpdate
Upload status update callback- Parameters:
bytesUploaded
-total
-
-
onUploadCompleted
Upload completed callback -
newMultipartWebRequest
public MultipartServletWebRequest newMultipartWebRequest(Bytes maxSize, String upload) throws org.apache.commons.fileupload2.core.FileUploadException Description copied from class:ServletWebRequest
Creates multipart web request from this request.- Overrides:
newMultipartWebRequest
in classServletWebRequest
- Parameters:
maxSize
- max allowed size of requestupload
- upload identifier forUploadInfo
- Returns:
- multipart request
- Throws:
org.apache.commons.fileupload2.core.FileUploadException
-
newMultipartWebRequest
public MultipartServletWebRequest newMultipartWebRequest(Bytes maxSize, String upload, org.apache.commons.fileupload2.core.FileItemFactory factory) throws org.apache.commons.fileupload2.core.FileUploadException Description copied from class:ServletWebRequest
Creates multipart web request from this request.- Overrides:
newMultipartWebRequest
in classServletWebRequest
- Parameters:
maxSize
- max allowed size of requestupload
- upload identifier forUploadInfo
- Returns:
- multipart request
- Throws:
org.apache.commons.fileupload2.core.FileUploadException
-
getUploadInfo
RetrievesUploadInfo
from session, null if not found.- Parameters:
req
- http servlet request, not nullupload
- upload identifier- Returns:
UploadInfo
object from session, or null if not found
-
setUploadInfo
public static void setUploadInfo(jakarta.servlet.http.HttpServletRequest req, String upload, UploadInfo uploadInfo) Sets theUploadInfo
object into session.- Parameters:
req
- http servlet request, not nullupload
- upload identifieruploadInfo
-UploadInfo
object to be put into session, not null
-
clearUploadInfo
Clears theUploadInfo
object from session if one exists.- Parameters:
req
- http servlet request, not nullupload
- upload identifier
-