I have been looking for a WebDAV client to work on Android. Some of the WebDAV clients that are available are Jakarata Slide (which is now retired), JackRabbit (Apache open source) and Sardine (from Google code). I zeroed in on JackRabbit2.2.5 as Sardine was not working and did not want to spend time on debugging. But then JackRabbit did not work as well on Android. My first mistake was to download the jackrabbit-standalone.jar from the net, and trying to make it work. This was a 30+ MB file and hence not suitable for Android platform. Then I tried debugging the jackrabbit-webdav code. It internally uses some of the packages which Android does not support. After making all the "Android-happy" changes in the code, I built the jackrabbit-webdav-2.2.5.jar again using their pom.xml(maven). The files size was around 288 KB. I believe this can be optimized further, even though I did not spend much time in doing so later. :)
Here is a code snippet to upload a file to the WebDAV server using the jar:
Same way, the MoveMethod, CopyMethod, DeleteMethod, MkColMethod (create), PropFindMethod (list the directory contents) can be used.
Edited:
The above file do not contain the org.apache.commons.httpclient. You may want to dowload the same from the apache site and add to your project class path OR .....
As one of the readers had requested to provide a jar file which includes the "org.apache.commons.httpclient", I have rebuilt my library to accommodate this change. This library is heavier than the previous one.
Previously the commons-httpclient version 3.0 was used in my jackrabbit jar. As one of the readers of this post has pointed out, FileRequestEntity (for content chunking) was not being supported, I rebuilt my jar to include the same. This includes commons-httpclient version 3.1.
So those of you who would like to use FileRequestEntity API for larger file upload, you can download the latest version of my jar. Here you go: jackrabbit-webdav-2.2.6-jar-with-dependencies.jar (size: 919 KB)
The older version (without FileRequestEntity) i.e. 2.2.5-jar, support only InputStreamRequestEntity and not FileRequestEntity. So those of you who would upload file of smaller size around 2 KB, can use the older version of my library: jackrabbit-webdav-2.2.5-jar-with-dependencies (size 892 KB).
I would appreciate your feedback or acknowledgement in the form of comments or a g+ rating if my library has helped you. Thanks. :)
Here is a code snippet to upload a file to the WebDAV server using the jar:
File file = new File(filePath);
/*PutMethod is a class in the jackrabbit-webdav for uploading files in the server*/
PutMethod putMethod = new PutMethod(baseURI+ uploadPath+file.getName());
PutMethod putMethod = new PutMethod(baseURI+ uploadPath+file.getName());
RequestEntity requestEntity = new InputStreamRequestEntity(new FileInputStream(file));
putMethod.setRequestEntity(requestEntity);
//HttpClient httpClient
httpClient.executeMethod(putMethod);
You can download the jar file ! :).
Edited:
The above file do not contain the org.apache.commons.httpclient. You may want to dowload the same from the apache site and add to your project class path OR .....
As one of the readers had requested to provide a jar file which includes the "org.apache.commons.httpclient", I have rebuilt my library to accommodate this change. This library is heavier than the previous one.
Previously the commons-httpclient version 3.0 was used in my jackrabbit jar. As one of the readers of this post has pointed out, FileRequestEntity (for content chunking) was not being supported, I rebuilt my jar to include the same. This includes commons-httpclient version 3.1.
So those of you who would like to use FileRequestEntity API for larger file upload, you can download the latest version of my jar. Here you go: jackrabbit-webdav-2.2.6-jar-with-dependencies.jar (size: 919 KB)
The older version (without FileRequestEntity) i.e. 2.2.5-jar, support only InputStreamRequestEntity and not FileRequestEntity. So those of you who would upload file of smaller size around 2 KB, can use the older version of my library: jackrabbit-webdav-2.2.5-jar-with-dependencies (size 892 KB).
I would appreciate your feedback or acknowledgement in the form of comments or a g+ rating if my library has helped you. Thanks. :)