express #express
var Busboy = require('busboy');
var busboy = new Busboy({ headers: req.headers });
return new Promise((resolve) => {
busboy.on('file', function(fieldname, file, filename, encoding, mimetype) {
const buffers = [];
file.on('data', function(data) {
buffers.push(data);
});
file.on('end', () => {
co(function* () {
const result = yield client.put(`${userid}/${uuidv3(filename, uuidv3.DNS)}-${filename}`, Buffer.concat(buffers));
resolve({
url: result.url,
name: result.name
});
});
});
});
busboy.on('field', function(fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) {
console.log('Field [' + fieldname + ']: value: ');
});
req.pipe(busboy);
})