I want to upload a files content with a string prefixed and affixed with the file content directly to a site.
The tricky part here is i want to use minimal RAM or main memory.
I want to upload a files content with a string prefixed and affixed with
Share
Take a look at Java: HTTP PUT with HttpURLConnection or Upload a file using HTTP put in Java . Basically, just use a
HttpURLConnectionwith the ‘PUT’ or ‘POST’ method as appropriate. Obtain the OutputStream using.getOutputStream(). With this, you can write whatever you want to the server, in an efficient, streaming fashion. Write your header/prefix, then use a buffer of the appropriate size to copy over your file contents, then write your footer/suffix, then finally close the stream.