boolean caughtException = false;\r
GetMethod get = new GetMethod(mUri.toString() + WebdavUtils.encodePath(remoteFilepath));\r
\r
- // get.setHeader("Host", mUri.getHost());\r
- // get.setHeader("User-Agent", "Android-ownCloud");\r
-\r
int status = -1;\r
try {\r
status = executeMethod(get);\r
* @param contentType MIME type of the file.\r
* @return 'True' then the upload was successfully completed\r
*/\r
- public boolean putFile(String localFile, String remoteTarget,\r
- String contentType) {\r
+ public boolean putFile(String localFile, String remoteTarget, String contentType) {\r
boolean result = false;\r
+ boolean caughtException = false;\r
+ int status = 0;\r
\r
try {\r
- Log.e("ASD", contentType + "");\r
File f = new File(localFile);\r
FileRequestEntity entity = new FileRequestEntity(f, contentType);\r
entity.setOnDatatransferProgressListener(mDataTransferListener);\r
- Log.e("ASD", f.exists() + " " + entity.getContentLength());\r
PutMethod put = new PutMethod(mUri.toString() + WebdavUtils.encodePath(remoteTarget));\r
put.setRequestEntity(entity);\r
- Log.d(TAG, "" + put.getURI().toString());\r
- int status = executeMethod(put, 0);\r
- Log.d(TAG, "PUT method return with status " + status);\r
-\r
- if (status == HttpStatus.SC_OK || status == HttpStatus.SC_CREATED || status == HttpStatus.SC_NO_CONTENT) {\r
- result = true;\r
- Log.i(TAG, "Uploading, done");\r
- }\r
+ status = executeMethod(put);\r
\r
- } catch (final Exception e) {\r
- Log.i(TAG, "" + e.getMessage());\r
- result = false;\r
- }\r
+ result = (status == HttpStatus.SC_OK || status == HttpStatus.SC_CREATED || status == HttpStatus.SC_NO_CONTENT);\r
+ \r
+ Log.d(TAG, "PUT response for " + remoteTarget + " finished with HTTP status " + status);\r
+ \r
+ } catch (HttpException e) {\r
+ Log.e(TAG, "HTTP exception uploading " + localFile + " to " + remoteTarget, e);\r
+ caughtException = true;\r
\r
+ } catch (IOException e) {\r
+ Log.e(TAG, "I/O exception uploading " + localFile + " to " + remoteTarget, e);\r
+ caughtException = true;\r
+\r
+ } catch (Exception e) {\r
+ Log.e(TAG, "Unexpected exception uploading " + localFile + " to " + remoteTarget, e);\r
+ caughtException = true;\r
+ }\r
+ \r
+ if (!result && !caughtException) Log.e(TAG, "Upload of " + localFile + " to " + remoteTarget + " FAILED with HTTP status " + status);\r
+ \r
return result;\r
}\r
\r