Skip to content

Commit

Permalink
fix error when uploading attachments.
Browse files Browse the repository at this point in the history
  • Loading branch information
bdeterding committed Aug 7, 2018
1 parent e536665 commit 10486c9
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions app-android/app/src/main/java/de/tutao/tutanota/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ String getName(String absolutePath) {
return Utils.uriToFile(activity.getWebView().getContext(), absolutePath).getName();
}

String upload(final String absolutePath, final String targetUrl, final JSONObject headers) throws IOException, JSONException {
int upload(final String absolutePath, final String targetUrl, final JSONObject headers) throws IOException, JSONException {
File file = Utils.uriToFile(activity.getWebView().getContext(), absolutePath);
HttpURLConnection con = (HttpURLConnection) (new URL(targetUrl)).openConnection();
try {
Expand All @@ -195,10 +195,8 @@ String upload(final String absolutePath, final String targetUrl, final JSONObjec
con.setChunkedStreamingMode(4096); // mitigates OOM for large files (start uploading before the complete file is buffered)
addHeadersToRequest(con, headers);
con.connect();

IOUtils.copy(new FileInputStream(file), con.getOutputStream());

return con.getResponseCode() + "";
return con.getResponseCode();
} finally {
con.disconnect();
}
Expand Down

0 comments on commit 10486c9

Please sign in to comment.