mirror of
https://github.com/apache/cordova-plugin-file-transfer.git
synced 2026-02-02 00:00:05 +08:00
dep(server)!: bump forever@4.0.3, iconv@3.0.1, busboy@1.6.0 & rebuilt package-lock (#370)
* dep(server): bump forever@4.0.3, iconv@3.0.1, & rebuilt package-lock w/ v2 lock * dep(server)!: bump busboy@1.6.0 * refactor(server): apply additional changes to match busboy docs
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
const http = require('http');
|
||||
const stringify = require('json-stringify-safe');
|
||||
const Busboy = require('busboy');
|
||||
const busboy = require('busboy');
|
||||
const { Iconv } = require('iconv');
|
||||
|
||||
const port = process.env.PORT || 5001;
|
||||
@@ -15,26 +15,27 @@ function parseMultipartForm (req, res, finishCb) {
|
||||
|
||||
const fields = {};
|
||||
const files = {};
|
||||
const busboy = new Busboy({ headers: req.headers });
|
||||
const bb = busboy({ headers: req.headers });
|
||||
|
||||
busboy.on('file', function (fieldname, file, filename, encoding, mimetype) {
|
||||
bb.on('file', (name, file, info) => {
|
||||
const { filename } = info;
|
||||
const currentFile = { size: 0 };
|
||||
|
||||
file.on('data', function (data) {
|
||||
file.on('data', (data) => {
|
||||
currentFile.name = filename;
|
||||
currentFile.size += data.length;
|
||||
});
|
||||
|
||||
file.on('end', function () {
|
||||
file.on('close', () => {
|
||||
files.file = currentFile;
|
||||
});
|
||||
});
|
||||
|
||||
busboy.on('field', function (fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) {
|
||||
fields[fieldname] = val;
|
||||
bb.on('field', (name, val, info) => {
|
||||
fields[name] = val;
|
||||
});
|
||||
|
||||
busboy.on('finish', function () {
|
||||
bb.on('close', () => {
|
||||
console.log(stringify({ fields, files }));
|
||||
|
||||
// This is needed due to this bug: https://github.com/mscdex/busboy/issues/73
|
||||
@@ -43,7 +44,7 @@ function parseMultipartForm (req, res, finishCb) {
|
||||
}
|
||||
});
|
||||
|
||||
busboy.on('error', function (err) {
|
||||
bb.on('error', function (err) {
|
||||
console.error(`error: ${err}: ${JSON.stringify(err)}`);
|
||||
errorOccured = true;
|
||||
|
||||
@@ -51,7 +52,7 @@ function parseMultipartForm (req, res, finishCb) {
|
||||
res.end(`Could not parse multipart form: ${err}\n`);
|
||||
});
|
||||
|
||||
req.pipe(busboy);
|
||||
req.pipe(bb);
|
||||
}
|
||||
|
||||
function respondWithParsedForm (req, res, parseResultObj) {
|
||||
@@ -115,7 +116,7 @@ http.createServer(function (req, res) {
|
||||
req.on('data', function (chunk) {
|
||||
body += chunk;
|
||||
if (body.length > DIRECT_UPLOAD_LIMIT) {
|
||||
req.connection.destroy();
|
||||
req.socket.destroy();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -150,7 +151,7 @@ http.createServer(function (req, res) {
|
||||
res.end('404\n');
|
||||
}
|
||||
|
||||
console.log(req.connection.remoteAddress + ' ' + req.method + ' ' + req.url + ' ' + res.statusCode + ' ' + req.headers['user-agent']);
|
||||
console.log(req.socket.remoteAddress + ' ' + req.method + ' ' + req.url + ' ' + res.statusCode + ' ' + req.headers['user-agent']);
|
||||
}).listen(port, '0.0.0.0');
|
||||
|
||||
console.log('Server running on ' + port);
|
||||
|
||||
4656
tests/server/package-lock.json
generated
4656
tests/server/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -15,9 +15,9 @@
|
||||
"author": "Apache Software Foundation",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"busboy": "^0.3.1",
|
||||
"forever": "^4.0.1",
|
||||
"iconv": "^3.0.0",
|
||||
"busboy": "^1.6.0",
|
||||
"forever": "^4.0.3",
|
||||
"iconv": "^3.0.1",
|
||||
"json-stringify-safe": "^5.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user