FAQ Database Discussion Community


Multer module won't start

node.js,express,mean-stack,multer
I'm writing a web app using the MEAN stack. I installed multer via npm like so: sudo npm install -g multer and I require it in one of my routes files: var multer = require("multer"); I'm using nodemon and it throws the following error every time it restarts since I've...

How to send response to client when files is too large with Multer

javascript,node.js,express,multer
I'm using NodeJs Multer to upload files. I need to send response back to a client when file user tries to upload is too large. The problem is that onFileSizeLimit only has file as argument and I dont know how to send response to client. What I need to do...

Can't set headers after they are sent node js

javascript,node.js,express,multer
I'm trying to send some form data, but I get this error using express.js: Can't set headers after they are sent. This is my code so far: app.post('/api/users/profile/:username', isAuthenticated, userUploads, function(req, res, next) { if (req.params.username) { User.findOne({ username: req.params.username }, function(err, user) { if (err) return next(err); user.profile.name =...

Error: invalid json with multer and body-parser

json,node.js,form-data,body-parser,multer
I am currently using multer for multipart/form-data in node.js application alongside with body-parser. I tried to POST form-data using POSTMAN, but it is getting this error. Error: invalid json at parse (/Users/k/Documents/application/node_modules/body-parser/lib/types/json.js:79:15) at /Users/k/Documents/application/node_modules/body-parser/lib/read.js:102:18 at IncomingMessage.onEnd (/Users/k/Documents/application/node_modules/body-parser/node_modules/raw-body/index.js:136:7) at IncomingMessage.g (events.js:199:16) at...

Passing data from server/app.js to controller Angular-fullstack + multer

javascript,angularjs,node.js,express,multer
I'm struggling to get a filename passed from server/app.js to a controller in client/app/ I am using Multer to deal with the file upload which is working fine but i need to pass the filename back to the client to display it in the next view. Here is the code...

Error handling when uploading file using multer with expressjs

node.js,express,multer,busboy
I am using multer to save the file on server developed through express & nodejs. I am usign following code. var express = require('express'), multer = require('multer') var app = express() app.get('/', function(req, res){ res.send('hello world'); }); app.post('/upload',[ multer({ dest: './uploads/'}), function(req, res){ res.status(204).end() }]); app.listen(3000); Multer saves the file...

What is wrong with Nodejs?

node.js,express,runtime-error,middleware,multer
I am using multer to handle upload image. app.use(multer({ dest: './public/photos', rename: function (fieldname, filename) { return filename+Date.now(); }, onFileUploadStart: function (file) { console.log(file.originalname + ' is starting ...') }, onFileUploadComplete: function (file) { console.log(file.fieldname + ' uploaded to ' + file.path) //a='asass'; done=true; } })); app.post('/api/photo',function(req,res){ if(done==true){ //ERROR here...

node multer AWS single file multiple upload

node.js,amazon-web-services,openshift,multer
Issue trying to upload images Openshift node/express/multer to AWS. The console tells me that there are multiple uploads of the same image and the resulting file on AWS is truncated and broken. I took all the client side ajax out and am just using a standard form upload. Express 3.2.5....

Post file from one server to another,using node.js , needle , busboy/multer

node.js,multer,busboy
I would like to move a small image from one server to another (both running node). As I search, I haven't found enough. This post remains unanswered. As I started experimenting I wrote the following to the first server : app.post("/move_img", function(req, res) { console.log("post handled"); fs.readFile(__dirname + "/img_to_move.jpg", function(err,...

How to upload files using multiple files input element?

angularjs,node.js,file-upload,express,multer
I'm trying to upload multiple files from multiple input element in one form. For exemple : <form id="category-form" method="post" enctype="multipart/form-data" class="form" name="form"> <div class="form-group"> <p>Pictures of the A Category</p> <input id="a_pics" accept="image/*" type="file" class="file" multiple="true" my-file-upload="a_pics" required/> </div> <div class="form-group"> <p>Pictures of the B Category</p> <input id="b_pics" accept="image/*" type="file" class="file"...

How to handle expressjs middleware request. post request remains pending made by dropzone

node.js,express,dropzone.js,multer
I am using dropzone to upload the file. On the server side I am using node and expressjs. I am also using multer as the file handling middleware. dropzone makes a call to one endpoint to save the file on the server. On the server side, I created an endpoint...

multer nodejs modules onFileUploadStart file.size returns 0

node.js,file-upload,asyncfileupload,multer
I am creating an app that receives file from several clients in node.js. For that i use express multer node modules. In the following code I deal with the file upload: app.use(multer({ dest: './uploads/', rename: function (fieldname, filename){ return filename; }, onFileUploadStart: function(file){ console.log("file size: " + file.size); console.log(file.originalname +...

ExpressJS Multer: Upload image to server

express,multer
I'm newer with Node.js and Express.js. I want to upload first a image into the server (directory: uploads/spots), and then (synchronous) upload the rest of form data in MongoDB. I'm using REST (Method Post) app.route('/spots').post(users.requiresLogin, spots.create); and I'm using Multer for updating the image into the server, and works. app.use(multer(...

Set multer properties inside an express route

node.js,express,multer
Instead of attaching multer to the entire express app, i am trying to include it just for specific routes, which is better since you will be preventing uploads to every route handling post. Problem is, i am unable to set it properties inside a route. var router = require('express').Router(), multer...

What file(s) should I be changing when adding dependencies in Node.js?

javascript,node.js,express,multer
I'm currently trying to add Multer to my Node.js app but having trouble figuring out where the code should actually be placed. In Node.js (while using Express) there are two files: bin/www & app.js. Both look somewhat similar. I'm trying to add the following code: var multer = require('multer'); Should...