public abstract class HttpUploadRequest extends Object
Constructor and Description |
---|
HttpUploadRequest(Context context,
String uploadId,
String serverUrl)
Creates a new http upload request.
|
Modifier and Type | Method and Description |
---|---|
HttpUploadRequest |
addArrayParameter(String paramName,
List<String> list)
Adds a parameter with multiple values to this upload request.
|
HttpUploadRequest |
addArrayParameter(String paramName,
String... array)
Adds a parameter with multiple values to this upload request.
|
HttpUploadRequest |
addHeader(String headerName,
String headerValue)
Adds a header to this upload request.
|
HttpUploadRequest |
addParameter(String paramName,
String paramValue)
Adds a parameter to this upload request.
|
HttpUploadRequest |
setAutoDeleteFilesAfterSuccessfulUpload(boolean autoDeleteFiles)
Sets the automatic file deletion after successful upload.
|
HttpUploadRequest |
setBasicAuth(String username,
String password)
Sets the HTTP Basic Authentication header.
|
HttpUploadRequest |
setCustomUserAgent(String customUserAgent)
Sets the custom user agent to use for this upload request.
|
HttpUploadRequest |
setMaxRetries(int maxRetries)
Sets the maximum number of retries that the library will do if an error occurs,
before returning an error.
|
HttpUploadRequest |
setMethod(String method)
Sets the HTTP method to use.
|
HttpUploadRequest |
setNotificationConfig(UploadNotificationConfig config)
Sets custom notification configuration.
|
HttpUploadRequest |
setUsesFixedLengthStreamingMode(boolean fixedLength)
Sets if this upload request is using fixed length streaming mode.
|
String |
startUpload()
Start the background file upload service.
|
public HttpUploadRequest(Context context, String uploadId, String serverUrl)
context
- application contextuploadId
- unique ID to assign to this upload request. If is null or empty, a random
UUID will be automatically generated. It's used in the broadcast receiver
when receiving updates.serverUrl
- URL of the server side script that handles the requestpublic final String startUpload() throws IllegalArgumentException, MalformedURLException
IllegalArgumentException
- if one or more arguments passed are invalidMalformedURLException
- if the server URL is not validpublic HttpUploadRequest setNotificationConfig(UploadNotificationConfig config)
config
- the upload configuration object or null if you don't want a notification
to be displayedHttpUploadRequest
public HttpUploadRequest setAutoDeleteFilesAfterSuccessfulUpload(boolean autoDeleteFiles)
autoDeleteFiles
- true to auto delete files included in the
request when the upload is completed successfully.
By default this setting is set to false, and nothing gets deleted.HttpUploadRequest
public HttpUploadRequest addHeader(String headerName, String headerValue)
headerName
- header nameheaderValue
- header valueHttpUploadRequest
public HttpUploadRequest setBasicAuth(String username, String password)
username
- HTTP Basic Auth usernamepassword
- HTTP Basic Auth passwordHttpUploadRequest
public HttpUploadRequest addParameter(String paramName, String paramValue)
paramName
- parameter nameparamValue
- parameter valueHttpUploadRequest
public HttpUploadRequest addArrayParameter(String paramName, String... array)
paramName
- parameter namearray
- valuesHttpUploadRequest
public HttpUploadRequest addArrayParameter(String paramName, List<String> list)
paramName
- parameter namelist
- valuesHttpUploadRequest
public HttpUploadRequest setMethod(String method)
method
- new HTTP method to useHttpUploadRequest
public HttpUploadRequest setCustomUserAgent(String customUserAgent)
customUserAgent
- custom user agent stringHttpUploadRequest
public HttpUploadRequest setMaxRetries(int maxRetries)
maxRetries
- number of maximum retries on errorHttpUploadRequest
public HttpUploadRequest setUsesFixedLengthStreamingMode(boolean fixedLength)
HttpUploadTask.getBodyLength()
will be automatically used to properly set the
underlying HttpURLConnection
, otherwise chunked streaming mode will be used.fixedLength
- true to use fixed length streaming mode (this is the default setting) or
false to use chunked streaming mode.HttpUploadRequest