lookfirst / sardine

an easy to use webdav client for java
Other
579 stars 185 forks source link

How to create folder tree as a/b/c/d? #293

Closed rvbb closed 1 year ago

rvbb commented 6 years ago

I tried to create a folder tree such as a/b/c/d, but Sardine always don't allow: 405 or 409 error will be replied.

public boolean createFolder(String folderName) throws Exception { try { this.sardine.createDirectory(this.baseUrl + "/" + folderName + "/"); return true; } catch (Exception e) { e.printStackTrace(); return false; } }
public boolean createFolderTree(String folderTree, String parentFolder) throws Exception { try { if(Util.empty(folderTree) || folderTree.indexOf("/") < 0) { return true; } String parentFirst = folderTree.substring(0, folderTree.indexOf("/")); String subFolderTree = folderTree.substring(folderTree.indexOf("/") + 1); if(!Util.empty(parentFirst)) { if(!Util.empty(parentFolder)) { createFolder(parentFolder + "/" + parentFirst);
}else { createFolder(parentFirst); } }
createFolderTree(subFolderTree, parentFirst); return true; } catch (Exception e) { e.printStackTrace(); return false; } } `

Plz support.