1

I want to upload data stored in memory to a web server as a .csv file with a particular name. Is there anyway to do this in android without writing the data to storage? That is, is it possible to create a virtual file in RAM and upload it to a web server without creating a file in the phone's filesystem?

xSooDx
  • 493
  • 1
  • 5
  • 19

1 Answers1

0

If you mean upload byte array to your HTTP server by POST then please take a look into this answer.

Android: Sending a byte[] array via Http POST

It should solve your problem.

J.D.1731
  • 385
  • 3
  • 14
  • I am not looking for a normal POST request, but rather like how in a browser, when you have to upload a file, you select it in the file explorer, and then the file gets uploaded. Here, I have the data in memory, but I want to upload it as a file, not just a byte array. – xSooDx Jul 10 '17 at 08:35
  • Usually when you use browser in background of your action browser uses POST method to sent file to server. The other way is FTP server which works differently. – J.D.1731 Jul 10 '17 at 08:37
  • I want to upload a file because the API i am working with demands it. I just want to avoid the overhead of writing data to storage and then upload the file. I am aware that the browser uses a POST request, but it also does extra things to indicate to the server that it is a file upload. Like how in PHP, the `$_FILE` array gets populated when you upload a file. – xSooDx Jul 10 '17 at 08:43
  • I'm not really sure how you want to achieve it. Usually you are using HTTP POST to send FILE and that's pretty easy to do. Probably you will have to use some authorization header to make it work because of security on your server side. However it depends of your server API. Please remember that PHP code is working on server side, so that's sth different than Android App which is basically a client app. – J.D.1731 Jul 10 '17 at 08:47