use header for file metadata

This commit is contained in:
Danny Coates 2017-06-29 10:27:36 -07:00
parent 4cb34844aa
commit 05fe534e14
No known key found for this signature in database
GPG key ID: 4C442633C62E00CB
4 changed files with 44 additions and 41 deletions

View file

@ -75,9 +75,7 @@ class FileSender extends EventEmitter {
const dataView = new DataView(encrypted);
const blob = new Blob([dataView], { type: file.type });
const fd = new FormData();
fd.append('fname', file.name);
fd.append('data', blob, file.name);
fd.append('aad', arrayToHex(this.aad));
const xhr = new XMLHttpRequest();
@ -102,6 +100,7 @@ class FileSender extends EventEmitter {
};
xhr.open('post', '/upload/' + fileId, true);
xhr.setRequestHeader('X-File-Metadata', JSON.stringify({ aad: arrayToHex(this.aad), iv: fileId, filename: file.name }))
xhr.send(fd);
});
})