I have a text file on my android device. I need to send this text file from the Android to a web server, using an http request, displaying the content. Is that case for a stream? I don't know how to send the entire file
Asked
Active
Viewed 279 times
1 Answers
0
Following code will help:
API 22: Using HttpClient and "binary/octet-stream"
How to send a file in Android from mobile to server using http?
API23: Using HttpUrlConnection
Sending files using POST with HttpURLConnection
Or, you can use Retrofit. It is powerful, robust, easy http library.
Tutorial: https://futurestud.io/blog/retrofit-how-to-upload-files

Community
- 1
- 1

Stanley Ko
- 3,383
- 3
- 34
- 60
-
OK, I added link of example using HttpUrlConnection(above API23.) But I suggest you to use Retrofit, it is much better. – Stanley Ko Mar 10 '16 at 13:12
-
I can't understand what do I have to change.. Please help – Simo Mar 10 '16 at 13:35
-
Oh I think you need to upload your text file. Can you show me you code? – Stanley Ko Mar 10 '16 at 13:55
-
I copied the code that you linked me, compatible with API23 – Simo Mar 10 '16 at 13:59
-
And, did it worked? Let me show your code, then I can understand where is the troubling point. – Stanley Ko Mar 10 '16 at 22:49