In android, how do I send a file(data) from a mobile device to server using http.
相关问题
- Angular RxJS mergeMap types
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
the most effective method is to use android-async-http
You can use this code to upload a file:
Note that you can put this code directly into your main Activity, no need to create a background Task explicitly. AsyncHttp will take care of that for you!
the most effective method is to use
org.apache.http.entity.mime.MultipartEntity;
see this code from the link using
org.apache.http.entity.mime.MultipartEntity;
Added:
Example Link
Wrap it all up in an Async task to avoid threading errors.
Easy, you can use a Post request and submit your file as binary (byte array).
This can be done with a HTTP Post request to the server: