public class MultipartHttp
extends java.lang.Object
implements java.io.Serializable
Constructor and Description |
---|
MultipartHttp() |
Modifier and Type | Method and Description |
---|---|
static Datum |
getBinaryPart(javax.servlet.http.Part part,
java.io.File file)
Get the content of a large binary part as a datum.
|
static byte[] |
getBytesPart(javax.servlet.http.Part part)
Get the content of a part as an array of bytes
|
static java.util.Map<java.lang.String,java.util.List<Datum>> |
getMultipartDatums(javax.servlet.http.HttpServletRequest request,
java.util.Set<java.io.File> tempFiles)
Get datums from the parts of an HTTP request with
multipart form data content.
|
static java.util.Map<java.lang.String,Datum> |
getMultipartUniqueDatums(javax.servlet.http.HttpServletRequest request,
java.util.Set<java.io.File> tempFiles)
Get unique datums from the parts of an HTTP request with
multipart form data content.
|
static java.lang.String |
getStringPart(javax.servlet.http.Part part)
Get the content of a part as a string.
|
static Datum |
getTextPart(javax.servlet.http.Part part,
java.io.File file)
Get the content of a large text part as a datum.
|
static boolean |
isText(java.lang.String contentType)
Determine whether a content type is a text content type.
|
Response |
makeJsonWithBinaryRequest(java.lang.String requestURL,
java.util.Map<java.lang.String,Datum> values,
java.util.Map<java.lang.String,java.lang.String> meta,
java.lang.String refurl,
java.lang.String oneTimeKey)
Make a request with multipart form encoded content conveying
a set of values, optionally some metadata, optionally a
reference URL, and optionally a one-time key.
|
Response |
makeMultipartRequest(java.lang.String requestURL,
java.util.Map<java.lang.String,Datum> partDatums)
Make an HTTP POST request with multipart form encoded content
|
void |
makeMultipartResponse(java.util.Map<java.lang.String,Datum> result,
javax.servlet.http.HttpServletResponse response)
Add multipart content to an HTTP response.
|
public Response makeJsonWithBinaryRequest(java.lang.String requestURL, java.util.Map<java.lang.String,Datum> values, java.util.Map<java.lang.String,java.lang.String> meta, java.lang.String refurl, java.lang.String oneTimeKey) throws java.lang.Exception
requestURL
- the URL to which the request is to be madevalues
- the values to be conveyed.meta
- the metadata to be conveyed, in the form
of a set of name-value pairs.refUrl
- a reference URL from which data can be obtained,
or null. (This is often the requesting system's API URL.)key
- a one-time key, or nulljava.lang.Exception
public Response makeMultipartRequest(java.lang.String requestURL, java.util.Map<java.lang.String,Datum> partDatums) throws java.lang.Exception
requestURL
- the URL to which the request is to be madeparts
- the content of the request. Each name-datum pair
of the map is to be a part of the multipart request.java.lang.Exception
public void makeMultipartResponse(java.util.Map<java.lang.String,Datum> result, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
result
- the data to include in the response, supplied as
a String-Datum map. For each entry, a part will be generated with
the same name as the entry, and with content whose type is
application/octet-stream if the datum is a Binary datum, and
text/plain with utf8 encoding otherwise.response
- the response to which the content is to be added.java.lang.Exception
public static java.util.Map<java.lang.String,Datum> getMultipartUniqueDatums(javax.servlet.http.HttpServletRequest request, java.util.Set<java.io.File> tempFiles) throws java.lang.Exception
request
- an HTTP request with multipart form data content.tempFiles
- a set of temporary files to contain the content of
large parts of the input content.java.lang.Exception
public static java.util.Map<java.lang.String,java.util.List<Datum>> getMultipartDatums(javax.servlet.http.HttpServletRequest request, java.util.Set<java.io.File> tempFiles) throws java.lang.Exception
request
- an HTTP request with multipart form data content.tempFiles
- a set of temporary files to contain the content of
large parts of the input content.java.lang.Exception
public static boolean isText(java.lang.String contentType)
contentType
- a content type.public static byte[] getBytesPart(javax.servlet.http.Part part) throws java.io.IOException
part
- a part of multipart contentjava.io.IOException
public static java.lang.String getStringPart(javax.servlet.http.Part part) throws java.io.IOException
part
- a part of multipart contentjava.io.IOException
public static Datum getBinaryPart(javax.servlet.http.Part part, java.io.File file) throws java.lang.Exception
part
- a binary part of multipart contentfile
- a file to contain the content of the partjava.lang.Exception
public static Datum getTextPart(javax.servlet.http.Part part, java.io.File file) throws java.lang.Exception
part
- a text part of multipart contentfile
- a file to contain the content of the partjava.lang.Exception