java.lang.Object | |
↳ | com.microstrategy.web.platform.MultipartRequest |
The class MultipartRequest
allows servlets to process file
uploads. Formally speaking, it supports requests with
multipart/form-data
content type. This content type is used to
submit forms that has the multipart/form-data
encoding type,
which is used to upload files and is not directly supported by the Servlet
Specification.
The class MultipartRequest
takes an
HttpServletRequest
, parses it extracting any parameters and
files and exposes them through an API. Notice that the class
MultipartRequest
supports regular requests as well so that
it is possible to process any request using a single API.
File parameters are passed as MultipartRequest.File
objects,
which encapsulates the file's properties and contents. Regular parameters
are passed as String
objects.
Notice that the class MultipartRequest
supports a simplified
version of MIME entity headers, specifically it does not support character
escaping, header wrapping, comments nor any extensions. Also, it assumes that
parameters are sent using the western (iso-8859-1) character set. Finally, it
does not support multipart/mixed
parts, which are used to send
multiple files as a single parameter, and it assumes that the request is well
formed, so no error checking is performed.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
class | MultipartRequest.File | The class MultipartRequest.File encapsulates uploaded files. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
MultipartRequest()
Creates a new, empty
MultipartRequest with a default
expiration date. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
copyParameters(ContainerStringCollection params)
Copies all parameters from a request to this
MultipartRequest . | ||||||||||
static MultipartRequest |
get(int ID)
Gets a
MultipartRequest object given its ID . | ||||||||||
long |
getExpiration()
Gets the expiration of this
MultipartRequest object. | ||||||||||
synchronized String |
getFile()
Gets the file being uploaded.
| ||||||||||
MultipartRequest.File |
getFileParameter(String name)
Convenient method that returns the value of a
MultipartRequest.File parameter. | ||||||||||
ContainerStringCollection |
getFormAndQueryStrings()
Returns reqest parameter strings collection
| ||||||||||
int |
getID()
Gets the
ID of this MultipartRequest . | ||||||||||
Object |
getParameter(String name)
Returns the value of a given parameter, or
null if the
parameter doesn't exist. | ||||||||||
Iterator |
getParameterNames()
Returns an
Iterator that iterates over the names of the
parameters contained in this MultipartRequest . | ||||||||||
Object[] |
getParameterValues(String name)
Returns an array of objects containing all of the values the given
request parameter has, or
null if the parameter does not
exist. | ||||||||||
synchronized int |
getProcessed()
Gets the number of bytes of the request's body already processed.
| ||||||||||
String |
getStringParameter(String name)
Convenient method that returns the value of a
String
parameter. | ||||||||||
synchronized int |
getTotal()
Gets the total number of bytes of the request.
| ||||||||||
void |
parseRequest(String contentType, InputStream requestStream)
Parses a request, populating this
MultipartRequest . | ||||||||||
void |
release()
Releases this
MultipartRequest object and all of its
parameters. | ||||||||||
void |
setExpiration(long expiration)
Sets the expiration date for this
MultipartRequest . | ||||||||||
synchronized void |
setTotal(int total)
Sets the total number of bytes of the request.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Creates a new, empty MultipartRequest
with a default
expiration date.
Copies all parameters from a request to this
MultipartRequest
.
params | request parameters |
---|
Gets a MultipartRequest
object given its ID
.
ID | object ID |
---|
ID
or null
if it doesn't exist or if it was released
Gets the expiration of this MultipartRequest
object.
Gets the file being uploaded.
Convenient method that returns the value of a
MultipartRequest.File
parameter. If the parameter has
multiple values, returns just the first one. Use the method
getParameterValues(String)
to get all values.
name | name of the desired parameter |
---|
MultipartRequest.File
, or null
if the
parameter does not exist
Returns reqest parameter strings collection
Gets the ID
of this MultipartRequest
. Each
object is guaranteed to have a unique ID
.
ID
of this object
Returns the value of a given parameter, or null
if the
parameter doesn't exist. The value of the parameter is a
String
or a MultipartRequest.File
object. If the
parameter has multiple values, returns just the first one. Use the
method getParameterValues(String)
to get all values.
name | name of the desired parameter |
---|
Returns an Iterator
that iterates over the names of the
parameters contained in this MultipartRequest
. The names of
the parameters are String
objects.
Iterator
Returns an array of objects containing all of the values the given
request parameter has, or null
if the parameter does not
exist. The values of the parameters are String
or
MultipartRequest.File
objects.
name | name of the parameter desired |
---|
Gets the number of bytes of the request's body already processed. This method can be called by another thread.
Convenient method that returns the value of a String
parameter. If the parameter has multiple values, returns just the first
one. Use the method getParameterValues(String)
to get all
values.
name | name of the desired parameter |
---|
String
, or null
if the parameter does
not exist
Gets the total number of bytes of the request.
Parses a request, populating this MultipartRequest
. If the
content type of the request is multipart/form-data
, parses
it, extracting any parameters and files, populating this object.
contentType | content type |
---|---|
requestStream | an input stream representing request to parse |
IOException | if an error occurs while reading the request, writing to temporary files, or if the pushback buffer is too small |
---|
Releases this MultipartRequest
object and all of its
parameters. This method should be called when this object is not needed
anymore. If this object is not explicitly released before its expiration,
it will be automatically released when it expires.
IOException | if an error occurs while releasing the temporary files |
---|
Sets the expiration date for this MultipartRequest
. The
expiration date is specified using the same base time as the one used by
the method System.currentTimeMillis()
.
expiration | expiration date |
---|
Sets the total number of bytes of the request.
total | total number of bytes |
---|