Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FileInputStream fileInputStream = new FileInputStream(selectedFile);
- URL url = new URL(SERVER_URL);
- connection = (HttpsURLConnection) url.openConnection();
- connection.setDoInput(true);//Allow Inputs
- connection.setDoOutput(true);//Allow Outputs
- connection.setUseCaches(false);//Don't use a cached Copy
- connection.setChunkedStreamingMode(1024);
- connection.setRequestMethod("POST");
- connection.setRequestProperty("Connection", "Keep-Alive");
- connection.setRequestProperty("Cache-Control", "no-cache, must-revalidate");
- connection.setRequestProperty("Expires", "Sat, 26 Jul 1997 05:00:00 GMT");
- connection.setRequestProperty("ENCTYPE", "multipart/form-data");
- connection.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary);
- connection.setRequestProperty("uploaded_file",selectedFilePath);
- InputStream in = connection.getInputStream();
- byte data[] = new byte[1024];
- int counter = -1;
- String jsonstring = "";
- while( (counter = in.read(data)) != -1){
- jsonString += new String(data, 0, counter);
- }
- Log.d("Debug", " JSON String: " + jsonString);
Add Comment
Please, Sign In to add comment