X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/435b31ba4f3597cc7a43270cd4a54fb0180956c1..5f61cb15552eb2fda01716078a9191b88cebf764:/src/eu/alefzero/webdav/WebdavClient.java diff --git a/src/eu/alefzero/webdav/WebdavClient.java b/src/eu/alefzero/webdav/WebdavClient.java index 6e1d287b..f7cc060e 100644 --- a/src/eu/alefzero/webdav/WebdavClient.java +++ b/src/eu/alefzero/webdav/WebdavClient.java @@ -47,6 +47,7 @@ public class WebdavClient extends HttpClient { private Credentials mCredentials; final private static String TAG = "WebdavClient"; private static final String USER_AGENT = "Android-ownCloud"; + private OnUploadProgressListener mUploadProgressListener; public WebdavClient(Uri uri) { mUri = uri; @@ -74,17 +75,23 @@ public class WebdavClient extends HttpClient { public boolean downloadFile(String filepath, File targetPath) { // HttpGet get = new HttpGet(mUri.toString() + filepath.replace(" ", // "%20")); + String[] splitted_filepath = filepath.split("/"); + filepath = ""; + for (String s : splitted_filepath) { + if (s.equals("")) continue; + filepath += "/" + URLEncoder.encode(s); + } - Log.e("ASD", mUri.toString() + URLDecoder.decode(filepath) + ""); + Log.e("ASD", mUri.toString() + filepath.replace(" ", "%20") + ""); GetMethod get = new GetMethod(mUri.toString() - + URLEncoder.encode(filepath)); + + filepath.replace(" ", "%20")); // get.setHeader("Host", mUri.getHost()); // get.setHeader("User-Agent", "Android-ownCloud"); try { - Log.e("ASD", get.toString()); int status = executeMethod(get); + Log.e(TAG, "status return: " + status); if (status != HttpStatus.SC_OK) { return false; } @@ -104,6 +111,10 @@ public class WebdavClient extends HttpClient { return true; } + public void setUploadListener(OnUploadProgressListener listener) { + mUploadProgressListener = listener; + } + public boolean putFile(String localFile, String remoteTarget, String contentType) { boolean result = true; @@ -111,7 +122,8 @@ public class WebdavClient extends HttpClient { try { Log.e("ASD", contentType + ""); File f = new File(localFile); - RequestEntity entity = new FileRequestEntity(f, contentType); + FileRequestEntity entity = new FileRequestEntity(f, contentType); + entity.setOnUploadProgressListener(mUploadProgressListener); Log.e("ASD", f.exists() + " " + entity.getContentLength()); PutMethod put = new PutMethod(mUri.toString() + remoteTarget); put.setRequestEntity(entity);