public class MultipartUploadRequest extends HttpUploadRequest
| Constructor and Description |
|---|
MultipartUploadRequest(Context context,
String serverUrl)
Creates a new multipart upload request and automatically generates an upload id, that will
be returned when you call
UploadRequest.startUpload(). |
MultipartUploadRequest(Context context,
String uploadId,
String serverUrl)
Creates a new multipart upload request.
|
| Modifier and Type | Method and Description |
|---|---|
MultipartUploadRequest |
addArrayParameter(String paramName,
List<String> list)
Adds a parameter with multiple values to this upload request.
|
MultipartUploadRequest |
addArrayParameter(String paramName,
String... array)
Adds a parameter with multiple values to this upload request.
|
MultipartUploadRequest |
addFileToUpload(String path,
String parameterName)
Adds a file to this upload request, without setting file name and content type.
|
MultipartUploadRequest |
addFileToUpload(String path,
String parameterName,
String fileName)
Adds a file to this upload request, without setting the content type, which will be
automatically detected from the file extension.
|
MultipartUploadRequest |
addFileToUpload(String filePath,
String parameterName,
String fileName,
String contentType)
Adds a file to this upload request.
|
MultipartUploadRequest |
addHeader(String headerName,
String headerValue)
Adds a header to this upload request.
|
MultipartUploadRequest |
addParameter(String paramName,
String paramValue)
Adds a parameter to this upload request.
|
MultipartUploadRequest |
setAutoDeleteFilesAfterSuccessfulUpload(boolean autoDeleteFiles)
Sets the automatic file deletion after successful upload.
|
MultipartUploadRequest |
setBasicAuth(String username,
String password)
Sets the HTTP Basic Authentication header.
|
MultipartUploadRequest |
setCustomUserAgent(String customUserAgent)
Sets the custom user agent to use for this upload request.
|
MultipartUploadRequest |
setMaxRetries(int maxRetries)
Sets the maximum number of retries that the library will try if an error occurs,
before returning an error.
|
MultipartUploadRequest |
setMethod(String method)
Sets the HTTP method to use.
|
MultipartUploadRequest |
setNotificationConfig(UploadNotificationConfig config)
Sets custom notification configuration.
|
MultipartUploadRequest |
setUsesFixedLengthStreamingMode(boolean fixedLength)
Sets if this upload request is using fixed length streaming mode.
|
MultipartUploadRequest |
setUtf8Charset()
Sets the charset for this multipart request to UTF-8.
|
setDelegate, startUploadpublic MultipartUploadRequest(Context context, String uploadId, String serverUrl)
context - application contextuploadId - unique ID to assign to this upload request.UploadServiceBroadcastReceiver,
you know to which upload they refer to.serverUrl - URL of the server side script that will handle the multipart form upload.
E.g.: http://www.yourcompany.com/your/scriptpublic MultipartUploadRequest(Context context, String serverUrl)
UploadRequest.startUpload().context - application contextserverUrl - URL of the server side script that will handle the multipart form upload.
E.g.: http://www.yourcompany.com/your/scriptpublic MultipartUploadRequest addFileToUpload(String filePath, String parameterName, String fileName, String contentType) throws FileNotFoundException, IllegalArgumentException
filePath - path to the file that you want to uploadparameterName - Name of the form parameter that will contain file's datafileName - File name seen by the server side script. If null, the original file name
will be usedcontentType - Content type of the file. You can use constants defined in
ContentType class. Set this to null or empty string to try to
automatically detect the mime type from the file. If the mime type can't
be detected, application/octet-stream will be used by defaultMultipartUploadRequestFileNotFoundException - if the file does not exist at the specified pathIllegalArgumentException - if one or more parameters are not validpublic MultipartUploadRequest addFileToUpload(String path, String parameterName, String fileName) throws FileNotFoundException, IllegalArgumentException
addFileToUpload(String, String, String, String).path - Absolute path to the file that you want to uploadparameterName - Name of the form parameter that will contain file's datafileName - File name seen by the server side script. If null, the original file name
will be usedMultipartUploadRequestFileNotFoundException - if the file does not exist at the specified pathIllegalArgumentException - if one or more parameters are not validpublic MultipartUploadRequest addFileToUpload(String path, String parameterName) throws FileNotFoundException, IllegalArgumentException
addFileToUpload(String, String, String, String)path - Absolute path to the file that you want to uploadparameterName - Name of the form parameter that will contain file's dataMultipartUploadRequestFileNotFoundException - if the file does not exist at the specified pathIllegalArgumentException - if one or more parameters are not validpublic MultipartUploadRequest setNotificationConfig(UploadNotificationConfig config)
UploadRequestsetNotificationConfig in class UploadRequestconfig - the upload configuration object or null if you don't want a notification
to be displayedUploadRequestpublic MultipartUploadRequest setAutoDeleteFilesAfterSuccessfulUpload(boolean autoDeleteFiles)
UploadRequestsetAutoDeleteFilesAfterSuccessfulUpload in class UploadRequestautoDeleteFiles - 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.UploadRequestpublic MultipartUploadRequest addHeader(String headerName, String headerValue)
HttpUploadRequestaddHeader in class HttpUploadRequestheaderName - header nameheaderValue - header valueHttpUploadRequestpublic MultipartUploadRequest setBasicAuth(String username, String password)
HttpUploadRequestsetBasicAuth in class HttpUploadRequestusername - HTTP Basic Auth usernamepassword - HTTP Basic Auth passwordHttpUploadRequestpublic MultipartUploadRequest addParameter(String paramName, String paramValue)
HttpUploadRequestaddParameter in class HttpUploadRequestparamName - parameter nameparamValue - parameter valueHttpUploadRequestpublic MultipartUploadRequest addArrayParameter(String paramName, String... array)
HttpUploadRequestaddArrayParameter in class HttpUploadRequestparamName - parameter namearray - valuesHttpUploadRequestpublic MultipartUploadRequest addArrayParameter(String paramName, List<String> list)
HttpUploadRequestaddArrayParameter in class HttpUploadRequestparamName - parameter namelist - valuesHttpUploadRequestpublic MultipartUploadRequest setMethod(String method)
HttpUploadRequestsetMethod in class HttpUploadRequestmethod - new HTTP method to useHttpUploadRequestpublic MultipartUploadRequest setCustomUserAgent(String customUserAgent)
HttpUploadRequestsetCustomUserAgent in class HttpUploadRequestcustomUserAgent - custom user agent stringHttpUploadRequestpublic MultipartUploadRequest setMaxRetries(int maxRetries)
UploadRequestsetMaxRetries in class UploadRequestmaxRetries - number of maximum retries on errorUploadRequestpublic MultipartUploadRequest setUsesFixedLengthStreamingMode(boolean fixedLength)
HttpUploadRequestHttpUploadTask.getBodyLength() will be automatically used to properly set the
underlying HttpURLConnection, otherwise chunked streaming mode will be used.setUsesFixedLengthStreamingMode in class HttpUploadRequestfixedLength - true to use fixed length streaming mode (this is the default setting) or
false to use chunked streaming mode.HttpUploadRequestpublic MultipartUploadRequest setUtf8Charset()