Whenever I commit the chunk upload supplying the access_token and upload_id, it always return an error code 400.
Here is the code.
private boolean commitChunk(String upload_id, String path){
int responseCode = 0;
try {
URL url = new URL("https://content.dropboxapi.com/1/commit_chunked_upload/auto/" + path);
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestProperty("Connection", "Keep-Alive");
connection.setRequestProperty("Authorization", "Bearer " + access_token_here);
connection.setRequestMethod("POST");
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
wr.writeBytes("upload_id=" + upload_id);
wr.flush();
wr.close();
responseCode = connection.getResponseCode();
System.out.println("response code: " + responseCode);
if(responseCode == 200){
connection.disconnect();
return true;
}
} catch (Exception exception) {
LogService.info(exception.getMessage());
System.out.println("Exception: " + exception.getMessage());
}
return false;
}
}
NOTE: I cannot use Dropbox SDK, and limited to Java1.4 only. So I can only do manual HTTP methods.