-
-
Notifications
You must be signed in to change notification settings - Fork 694
4.x Usage
Alex Gotev edited this page Oct 18, 2020
·
19 revisions
All the upload request methods are non blocking. They trigger a background upload service, so you can fire requests directly from your fragments, activities or services without concerns.
HTTP multipart/form-data upload (RFC2388)
This is the most common way to upload files on a server. It's the same kind of request that browsers do when you use the <form>
tag with one or more files. Here's a minimal example:
MultipartUploadRequest(context, serverUrl = "https://my.server.com")
.setMethod("POST")
.addFileToUpload(
filePath = filePath,
parameterName = "myFile"
).startUpload()
Check the other methods available in MultipartUploadRequest class. You can also add multiple headers, files and parameters. To monitor upload progress and status, check: https://github.com/gotev/android-upload-service/wiki/Monitor-Uploads
feature | description |
---|---|
multiple files in a single request | yes. There are many ways to do it. Example. |
support for HTTP Basic and Bearer Auth | yes. Add .setBasicAuth("username", "password") or .setBearerAuth("bearer-token") when you build the request |
add custom request headers | yes. You can also set them with request interceptors if you are using OkHttp stack. |
add custom request parameters | yes |
default charset | UTF-8. Non latin characters are supported out of the box. |
resuming uploads | no. If an upload fails at some point, the temporary data will be discarded automatically by your server and the upload will start from the beginning on the next request. The server sees a multipart request as a single stream of data, as per RFC specs. There's no way to resume a multipart upload. You have to start over. |