@tomsd/webdav-client
v2.0.0
Published
webdav client
Downloads
9
Readme
@tomsd/webdav-client
Installation
npm install @tomsd/webdav-client
Usage
import davc from "@tomsd/webdav-client";
const siteurl = "https://yoursite.any";
window.addEventListener("load", function(){
// get the files and the folders
davc.getDirectory(`${siteurl}/`).then(function(items){
console.log(items);
});
const dateStr = (new Date()).getTime().toString();
const folderName = dateStr;
const textfilename = dateStr+".txt";
const folderUrl = `${siteurl}/${folderName}`;
const fileUrl = `${siteurl}/${folderName}/${textfilename}`;
// create folder
davc.createFolder(folderUrl)
.then(function(){
console.log("folder created");
// write file
return davc.writeTextFile(fileUrl, textfilename);
})
.then(function(){
console.log("text written");
// read file
return davc.readTextFile(fileUrl);
})
.then(function(text){
console.log("read");
console.log(text);
// delete file
return davc.removeFile(fileUrl);
})
.then(function(){
console.log("removed");
// delete folder
return davc.removeFolder(folderUrl);
})
.then(function(){
console.log("folder is removed");
})
.catch((e) => console.error(e));
});