file/attachment upload, wiP

This commit is contained in:
azivner
2018-02-14 23:31:20 -05:00
parent 8028b09351
commit cdde6a4d8e
14 changed files with 166 additions and 93 deletions

View File

@@ -211,4 +211,26 @@ if (isElectron()) {
await noteTree.createNote(node, node.data.noteId, 'into', node.data.isProtected);
});
}
}
function uploadAttachment() {
$("#file-upload").trigger('click');
}
$("#file-upload").change(async function() {
const formData = new FormData();
formData.append('upload', this.files[0]);
const resp = await $.ajax({
url: baseApiUrl + 'attachments/upload/' + noteEditor.getCurrentNoteId(),
headers: server.getHeaders(),
data: formData,
type: 'POST',
contentType: false, // NEEDED, DON'T OMIT THIS
processData: false, // NEEDED, DON'T OMIT THIS
});
await noteTree.reload();
await noteTree.activateNode(resp.noteId);
});