multer

multer - req.file always undefined

若如初见. 提交于 2019-11-29 16:58:21
问题 I've looked at a lot of answer for this same question, but I haven't found a working solution yet. I am trying to make a web app that you can upload files to using express and multer, and I am having a problem that no files are being uploaded and req.file is always undefined. My code below 'use strict'; var express = require('express'); var path = require('path'); var multer = require('multer') var upload = multer({ dest: 'uploads/' }) var app = express(); require('dotenv').load(); app.use

MongoError when uploading a file using mongoose, gridfs-stream and multer

可紊 提交于 2019-11-29 15:35:08
问题 I am running express 4 using multer, gridfs-stream and mongoose with mongodb and I am attempting to upload a file and stream it to gridfs. The express route that does this is defined as: app.post('/uploadfile', function (req, res) { console.dir(req.files); // The mongodb instance created when the mongoose.connection is opened var db = mongoose.connection.db; // The native mongo driver which is used by mongoose var mongoDriver = mongoose.mongo; // Create a gridfs-stream var gfs = new Gridfs(db

Multer not accepting files in array format gives 'Unexpected File Error'

穿精又带淫゛_ 提交于 2019-11-29 14:17:03
问题 Multer is a module used along with node js and express to upload files. I am using ng-file upload module on the angular side. When I am sending multiple files one by one it works just fine without any errors whatsoever but when I am sending all files in one go in array format and then I am making necessary changes on the server side as suggested by Multer's github, still error comes. Here is the error Error: Unexpected field at makeError (C:\nodefiles\new\node_modules\multer\lib\make-error.js

How to upload file using multer or body-parser

坚强是说给别人听的谎言 提交于 2019-11-29 13:16:47
I am a NodeJS beginner, following along a book "Web Development with MongoDB and NodeJS". I am stuck at its chapter 6 with 'multer'. When I use multer for file uploads the server throws the following error: /Users/fk / Documents / imageuploader / node_modules / express / lib / application.js: 209 throw new TypeError('app.use() requires middleware functions'); ^ TypeError: app.use() requires middleware functions but when I replace it with bodyParser the server fires up but when I click the upload button it gives me the following error on the browser. 500 TypeError: Cannot read property 'file'

Node.js, multer and req.body empty

拜拜、爱过 提交于 2019-11-29 12:27:11
问题 Here it is my problem, I have a form where I can insert a file and a field but I receive only the file and not the parameter test ! Why? This is my code: app.js: var express = require('express'); var bodyParser = require('body-parser'); var app = express(); var port = 8000; var multer = require('multer'); // v1.0.5 var storage = multer.diskStorage({ destination: function (req, file, callback) { callback(null, './uploads'); }, filename: function (req, file, callback) { callback(null, file

Send blob data to node using fetch, multer, express

与世无争的帅哥 提交于 2019-11-29 07:33:31
问题 Trying to send a blob object to my node server. On the client side I'm recording some audio using MediaRecorder and then I want to send the file to my server for processing. saveButton.onclick = function(e, audio) { var blobData = localStorage.getItem('recording'); console.log(blobData); var fd = new FormData(); fd.append('upl', blobData, 'blobby.raw'); fetch('/api/test', { method: 'post', body: fd }) .then(function(response) { console.log('done'); return response; }) .catch(function(err){

Use Multer in Express Route? (Using MEANJS)

空扰寡人 提交于 2019-11-29 02:46:45
问题 I'm using Multer to upload images in Express 4. However, the examples all show Multer being defined in the express file as Middleware. I'd like to actually define some of the Multer behaviors in my app routing itself. Is this possible? The end result that I need is for my route function to recognize when the upload is finished before it sends the server response to the browser, so an image can be displayed to the user (right now I'm only getting a partial image displayed because the file hasn

Uploading image to amazon s3 using multer-s3 nodejs

假如想象 提交于 2019-11-28 18:27:15
I am trying to upload an image to amazon s3 using multer-s3 , but I am getting this error: TypeError: Expected opts.s3 to be object node_modules/multer-s3/index.js:69:20 This is my server code: var upload = multer({ storage: s3({ dirname: '/', bucket: 'bucket', secretAccessKey: 'key', accessKeyId: 'key', region: 'us-west-2', filename: function (req, file, cb) { cb(null, file.originalname); } }) }); app.post('/upload', upload.array('file'), function (req, res, next) { res.send("Uploaded!"); }); Why I am getting this error? Complete and working Node Cheat | Upload to s3 using multer-s3 available

How to upload file using multer or body-parser

雨燕双飞 提交于 2019-11-28 07:13:30
问题 I am a NodeJS beginner, following along a book "Web Development with MongoDB and NodeJS". I am stuck at its chapter 6 with 'multer'. When I use multer for file uploads the server throws the following error: /Users/fk / Documents / imageuploader / node_modules / express / lib / application.js: 209 throw new TypeError('app.use() requires middleware functions'); ^ TypeError: app.use() requires middleware functions but when I replace it with bodyParser the server fires up but when I click the

nodejs + multer + angularjs for uploading without redirecting

Deadly 提交于 2019-11-27 15:14:06
I am using Nodejs + Multer +angularjs for uploading files on the server. i have a simple HTML file: <form action="/multer" method="post" enctype="multipart/form-data"> <input type="file" id="photo" name="photo"/> <button id="Button1">Upload</button> </form> Nodejs part: var multer = require('multer'); var storage = multer.diskStorage({ destination: function (req, file, cb) { cb(null, './uploads/') }, filename: function (req, file, cb) { cb(null, file.originalname) } }) app.post('/multer', upload.single('photo'), function (req, res) { res.end("File uploaded."); }); this works perfectly and the