public class UploadServlet.Contents extends Object
See http://www.w3.org/TR/html401/interact/forms.html#h-17.13.42 for a discussion of multipart/form-data.
All lines must end with \r\n. However, binary data may have \r\n in the middle of the material.
Modifier and Type | Field and Description |
---|---|
protected String |
filename
Filename associated with the part.
|
protected String |
mime
MIME code for the data in the part.
|
protected String |
name
Name of the part.
|
protected String |
transferEncoding
Content transfer encoding method for the
element of the transaction.
|
protected byte[] |
value
The byte array containing the data for this
part.
|
Constructor and Description |
---|
UploadServlet.Contents() |
Modifier and Type | Method and Description |
---|---|
byte[] |
getContents()
Obtains the byte array that was associated with this
part of the form.
|
int |
getContentsSize()
Obtains the size of the byte array that was associated with
this part of the form.
|
String |
getFilename()
Obtain the filename associated with the part.
|
String |
getMime()
Obtain mime type for part.
|
String |
getName()
Obtain the name of the part.
|
String |
getTransferEncoding()
Obtain the value for content-transfer-encoding.
|
void |
parseLine(String lineValue)
Parses header lines in an individual part of a multipart form.
|
void |
setContents(byte[] input)
Connect the byte array to the object.
|
String |
toString() |
protected String transferEncoding
According to the documentation, there are various encoding methods that can be used such as base64 and quoted-printable. These have not been seen in the browsers I have used, but I may have to allow for these encoding methods.
protected byte[] value
public UploadServlet.Contents()
public String getFilename()
If the data was not taken from a file, a null value is returned.
public String getMime()
MIME types would only be associated with data taken from files.
public String getTransferEncoding()
public byte[] getContents()
Obtains the byte array that was associated with this part of the form.
public int getContentsSize()
public void parseLine(String lineValue)
This algorithm works if the values for the name and filename are surrounded by double quotes, there are no escaped characters with the values, and there are no spaces between the start of the word name or filename and the corresponding closing quote. It also assumes that the name parameter comes before the filename parameter. I'm not sure if these assumptions are valid.
lineValue
- Line to be parsedpublic void setContents(byte[] input)
input
- Byte array to be attached to object