new EasySSLSocketFactory(), 443));\r
}\r
\r
+ /**\r
+ * Downloads a file in remoteFilepath to the local targetPath.\r
+ * \r
+ * @param remoteFilepath Path to the file in the remote server, URL DECODED. \r
+ * @param targetPath Local path to save the downloaded file.\r
+ * @return 'True' when the file is successfully downloaded.\r
+ */\r
public boolean downloadFile(String remoteFilepath, File targetPath) {\r
boolean ret = false;\r
- GetMethod get = new GetMethod(mUri.toString() + remoteFilepath);\r
+ GetMethod get = new GetMethod(mUri.toString() + WebdavUtils.encode(remoteFilepath));\r
HttpMethodParams params = get.getParams();\r
params.setSoTimeout(0); // that means "infinite timeout"; it's the default value, but let's make it explicit\r
get.setParams(params);\r
\r
/**\r
* Deletes a remote file via webdav\r
- * @param remoteFilePath\r
+ * @param remoteFilePath Remote file path of the file to delete, in URL DECODED format.\r
* @return\r
*/\r
public boolean deleteFile(String remoteFilePath){\r
- DavMethod delete = new DeleteMethod(mUri.toString() + remoteFilePath);\r
+ DavMethod delete = new DeleteMethod(mUri.toString() + WebdavUtils.encode(remoteFilePath));\r
try {\r
executeMethod(delete);\r
} catch (Throwable e) {\r
mDataTransferListener = listener;\r
}\r
\r
+ /**\r
+ * Creates or update a file in the remote server with the contents of a local file.\r
+ * \r
+ * \r
+ * @param localFile Path to the local file to upload.\r
+ * @param remoteTarget Remote path to the file to create or update, URL DECODED\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
boolean result = true;\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() + remoteTarget);\r
+ PutMethod put = new PutMethod(mUri.toString() + WebdavUtils.encode(remoteTarget));\r
HttpMethodParams params = put.getParams();\r
params.setSoTimeout(0); // that means "infinite timeout"; it's the default value, but let's make it explicit\r
put.setParams(params);\r
return returnCode;\r
}\r
\r
+ /**\r
+ * Creates a remote directory with the received path.\r
+ * \r
+ * @param path Path of the directory to create, URL DECODED\r
+ * @return 'True' when the directory is successfully created\r
+ */\r
public boolean createDirectory(String path) {\r
try {\r
- MkColMethod mkcol = new MkColMethod(mUri.toString() + path);\r
+ MkColMethod mkcol = new MkColMethod(mUri.toString() + WebdavUtils.encode(path));\r
int status = executeMethod(mkcol);\r
Log.d(TAG, "Status returned " + status);\r
Log.d(TAG, "uri: " + mkcol.getURI().toString());\r