tengo un server especial para subir archivos en nodejs q es este
var express = require("express");
var app = express();
var multer, storage, path, crypto;
multer = require('multer')
path = require('path');
crypto = require('crypto');
var form = "<!DOCTYPE HTML><html><body>" +
"<form method='post' action='/upload' enctype='multipart/form-data'>" +
"<input type='file' name='upload'/>" +
"<input type='submit' /></form>" +
"</body></html>";
app.get('/', function (req, res){
res.writeHead(200, {'Content-Type': 'text/html' });
res.end(form);
});
// Include the node file module
var fs = require('fs');
storage = multer.diskStorage({
destination: './uploads/',filename: function(req, file, callback) {
callback(null, Date.now() + "_" + file.originalname);
}
/* filename: function(req, file, cb) {
return crypto.pseudoRandomBytes(16, function(err, raw) {
if (err) {
return cb(err);
}
return cb(null, "" + (raw.toString('hex')) + (path.extname(file.originalname)));
});
} */
});
// Post files
app.post(
"/upload",
multer({
storage: storage
}).single('upload'), function(req, res) {
console.log(req.file);
console.log(req.body);
/* res.redirect("/uploads/" + req.file.filename); */
console.log(req.file.filename);
return res.status(200).end();
});
app.get('/uploads/:upload', function (req, res){
file = req.params.upload;
console.log(req.params.upload);
var img = fs.readFileSync(__dirname + "/uploads/" + file);
res.writeHead(200, {'Content-Type': 'image/png' });
res.end(img, 'binary');
});
port = 4000;
app.listen(port);
console.log("listen on port " + port)
y estoy tratando de subir un archivo de video desde android con el codigo q consegui en esta pag
https://www.simplifiedcoding.net/android-upload-video-to-server-using-php/
pero me genera el siguiente error al tratar de enviar el video
MulterError: Unexpected field at wrappedFileFilter (C:\Users\ray_c\OneDrive\Documentos\jdserver\node_modules\multer\index.js:40:19) at Busboy. (C:\Users\ray_c\OneDrive\Documentos\jdserver\node_modules\multer\lib\make-middleware.js:114:7) at emitMany (events.js:147:13) at Busboy.emit (events.js:224:7) at Busboy.emit (C:\Users\ray_c\OneDrive\Documentos\jdserver\node_modules\busboy\lib\main.js:38:33) at PartStream. (C:\Users\ray_c\OneDrive\Documentos\jdserver\node_modules\busboy\lib\types\multipart.js:213:13) at emitOne (events.js:116:13) at PartStream.emit (events.js:211:7) at HeaderParser. (C:\Users\ray_c\OneDrive\Documentos\jdserver\node_modules\dicer\lib\Dicer.js:51:16) at emitOne (events.js:116:13)
tienen alguna idea de q esta sucediendo y como puedo solucionarlo??