I want to split the image in the chunks for 4mb each and then upload to server.How can I achieve this for sending an image in multipart.
I have tried some way but I am getting media not supported error.
FileInputStream fileInputStream = new FileInputStream(selectedFile);
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);
I want the input in following way.
{
"blocks": [{
"hashdata": "dsfhsdfjhjsdfhj36278dhgjgddfsh7k",
"data": <base64 data>
},{
"hashdata": "abcdskjfkskdfh8772384374789327dh",
"data": <base64 data>
}]
}