T - Response expectedpublic abstract class MultiPartRequest<T> extends Request<T> implements Response.ProgressListener
| Modifier and Type | Class and Description |
|---|---|
static class |
MultiPartRequest.MultiPartParam
A representation of a MultiPart parameter
|
Request.Method, Request.Priority| Modifier and Type | Field and Description |
|---|---|
static int |
TIMEOUT_MS |
| Constructor and Description |
|---|
MultiPartRequest(int method,
java.lang.String url,
Response.Listener<T> listener,
Response.ErrorListener errorListener)
Creates a new request with the given method.
|
| Modifier and Type | Method and Description |
|---|---|
MultiPartRequest<T> |
addFile(java.lang.String name,
java.lang.String filePath)
Add a file to be uploaded in the multipart request
|
MultiPartRequest<T> |
addMultipartParam(java.lang.String name,
java.lang.String contentType,
java.lang.String value)
Add a parameter to be sent in the multipart request
|
MultiPartRequest<T> |
addStringParam(java.lang.String name,
java.lang.String value)
Add a string parameter to be sent in the multipart request
|
protected void |
deliverResponse(T response)
Subclasses must implement this to perform delivery of the parsed
response to their listeners.
|
java.util.Map<java.lang.String,java.lang.String> |
getFilesToUpload()
Get all the files to be uploaded for this request
|
java.util.Map<java.lang.String,MultiPartRequest.MultiPartParam> |
getMultipartParams()
Get all the multipart params for this request
|
java.lang.String |
getProtocolCharset()
Get the protocol charset
|
boolean |
isFixedStreamingMode() |
void |
onProgress(long transferredBytes,
long totalSize)
Callback method thats called on each byte transfer.
|
protected abstract Response<T> |
parseNetworkResponse(NetworkResponse response)
Subclasses must implement this to parse the raw network response
and return an appropriate response type.
|
void |
setFixedStreamingMode(boolean isFixedStreamingMode) |
void |
setOnProgressListener(Response.ProgressListener listener)
Set listener for tracking download progress
|
addMarker, cancel, compareTo, deliverError, getBody, getBodyContentType, getCacheEntry, getCacheKey, getEncodedUrlParams, getErrorListener, getHeaders, getMethod, getParams, getParamsEncoding, getPostBody, getPostBodyContentType, getPostParams, getPostParamsEncoding, getPriority, getRetryPolicy, getSequence, getTag, getTimeoutMs, getTrafficStatsTag, getUrl, hasHadResponseDelivered, isCanceled, markDelivered, overridePatch, parseNetworkError, setCacheEntry, setHeaders, setParams, setPriority, setRequestQueue, setRetryPolicy, setSequence, setShouldCache, setTag, shouldCache, shouldOverridePatch, toStringpublic static final int TIMEOUT_MS
public MultiPartRequest(int method,
java.lang.String url,
Response.Listener<T> listener,
Response.ErrorListener errorListener)
method - the request Method to useurl - URL to fetch the string atlistener - Listener to receive the String responseerrorListener - Error listener, or null to ignore errorspublic MultiPartRequest<T> addMultipartParam(java.lang.String name, java.lang.String contentType, java.lang.String value)
name - The name of the paramtercontentType - The content type of the paramtervalue - the value of the paramterpublic MultiPartRequest<T> addStringParam(java.lang.String name, java.lang.String value)
name - The name of the paramtervalue - the value of the paramterpublic MultiPartRequest<T> addFile(java.lang.String name, java.lang.String filePath)
name - The name of the file keyfilePath - The path to the file. This file MUST exist.protected abstract Response<T> parseNetworkResponse(NetworkResponse response)
RequestparseNetworkResponse in class Request<T>response - Response from the networkprotected void deliverResponse(T response)
RequestdeliverResponse in class Request<T>response - The parsed response returned by
Request.parseNetworkResponse(NetworkResponse)public void setOnProgressListener(Response.ProgressListener listener)
listener - public void onProgress(long transferredBytes,
long totalSize)
Response.ProgressListeneronProgress in interface Response.ProgressListenerpublic java.util.Map<java.lang.String,MultiPartRequest.MultiPartParam> getMultipartParams()
public java.util.Map<java.lang.String,java.lang.String> getFilesToUpload()
public java.lang.String getProtocolCharset()
public boolean isFixedStreamingMode()
public void setFixedStreamingMode(boolean isFixedStreamingMode)