Skip to content
Snippets Groups Projects
Commit 5aba377d authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire:
Browse files

Start Nextcloud upload implementation (#14)

parent bff3a2e5
Branches
No related tags found
No related merge requests found
Pipeline #12278 passed
......@@ -306,6 +306,36 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
});
}
uploadFiles(files) {
files.forEach((fileData) => this.uploadFile(fileData));
}
uploadFile(fileData) {
this.statusText = "Uploading " + fileData.filename + "...";
console.log(fileData);
// https://github.com/perry-mitchell/webdav-client#putfilecontents
this.webDavClient
.putFileContents(fileData.filename, f)
.then(contents => {
// create file to send via event
const file = new File([contents], fileData.basename, { type: fileData.mime });
console.log("binaryFile", file);
// send event
const data = {"file": file, "data": fileData};
const event = new CustomEvent("dbp-nextcloud-file-picker-file-uploaded",
{ "detail": data, bubbles: true, composed: true });
this.dispatchEvent(event);
this.statusText = "";
}).catch(error => {
console.error(error.message);
this.statusText = error.message;
});
}
/**
* Returns the parent directory path
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment