I'm trying to send the file through HttpUrlConnection method.
URL url = new URL(SERVER_URL);
connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);//Allow Inputs
connection.setDoOutput(true);//Allow Outputs
connection.setUseCaches(false);//Don't use a cached Copy
connection.setRequestMethod("POST");
connection.setRequestProperty("Connection", "Keep-Alive");
connection.setRequestProperty("ENCTYPE", "multipart/form-data");
connection.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary);
connection.setRequestProperty("uploaded_file",selectedFilePath);
sending the file with dataOutputStream.
dataOutputStream.writeBytes(lineEnd);
dataOutputStream.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);
But Not sure How to handle this HttlUrlConnection and fileoutputstream on server side.
I'm not sure i'm doing correct but trying to get input stream with
simple RequestMapping. This is my server side.
@RequestMapping(value="/fileUploadPage")
public String fileUpload(@Validated FileModel file, BindingResult result, ModelMap model,HttpServletRequest req) throws IOException {
How to handle 'httpUrlconnection outputstream' in here?
}