refactored upload away from multipart forms to binary data

This commit is contained in:
Danny Coates 2018-05-31 14:06:25 -07:00
parent 196d4211b6
commit af7a262ef0
No known key found for this signature in database
GPG key ID: 4C442633C62E00CB
9 changed files with 56 additions and 93 deletions

View file

@ -26,9 +26,8 @@ class FSStorage {
const filepath = path.join(this.dir, id);
const fstream = fs.createWriteStream(filepath);
file.pipe(fstream);
file.on('limit', () => {
file.unpipe(fstream);
fstream.destroy(new Error('limit'));
file.on('error', err => {
fstream.destroy(err);
});
fstream.on('error', err => {
fs.unlinkSync(filepath);