multer

Service for uploading multiple file using multer in node.js

萝らか妹 提交于 2019-12-13 00:27:28
问题 I have created class named FileUpload and made one function to upload multiple files using multer.I want to use this method in controller but i cannot to do so. i can not get other fields from request. Here is the FileUpload class : var multer = require('multer'); class FileUpload{ constructor(){ this.storage = null; this.filepath = null; this.upload = null; } uploadMultipleFile(req,res,path){ this.filepath = path; this.storage = multer.diskStorage({ destination : (req,file,callback) =>{

Node.js TypeError: Cannot read property 'path' of undefined

随声附和 提交于 2019-12-12 20:26:04
问题 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. Express and multer version as: "express": "^4.15.4", "multer": "^1.3.0" My configure.js looks this: multer = require('multer'); module.exports = function(app) { app.use(morgan('dev')); app.use(multer({ dest: path.join(_

Filter files on the basis of extension using Multer in Express JS

二次信任 提交于 2019-12-12 07:26:34
问题 As question title explains, I need to filter uploaded files on the basis of file extension. So, I went through the official docs and searched this website. What I've Tried I've tried solutions I came across. Files are being successfully uploaded, but the problem is how to filter files. Currently my Router.js file looks like this. Router.JS var multer = require('multer'); var storage = multer.diskStorage({ //multers disk storage settings destination: function (req, file, cb) { cb(null, '.

How to return id of uploaded file (upload with multer in nodejs express app)

耗尽温柔 提交于 2019-12-12 04:07:42
问题 I have an MEAN stack app and trying to upload file with multer. Upload is working fine the only problem is I want to return uploaded file's id. //multer settings for single upload var upload = multer({ storage: storage }).single('file'); app.post('/upload', upload, function (req, res) { //// ????? What to return and how? }); I'm subscribed to this post into angular2 service. Thank you for help. 回答1: var multer = require('multer'); // storage for upload file. var storage = multer.diskStorage({

How to encrypt file using express multer

左心房为你撑大大i 提交于 2019-12-12 03:57:21
问题 By having these simple few lines of code I've got file saved on server. router.post('/upload', upload.single('file'), function(req: Request, res: Response, next: Function) { console.log(req.file); res.json({ success: true, message: 'Uploaded' }); }); I want to encrypt the file before it is get saved. Is there any way I can do that? 回答1: Multer provides a rich set of events which can give you better control over your file uploads. Therefore, the order of execution is: onParseStart

Multer throwing weird error while uploading file via ng-file upload

耗尽温柔 提交于 2019-12-12 02:47:09
问题 I did some research upon this and I still don't know what is going on here. The google has irrelevant search result or the given error code/message. Here is my angular controller, simply based upon api code and samples of ng-file upload on ng-file upload. var app = angular.module('fileUpload', ['ngFileUpload']); app.controller('MyCtrl', ['$scope', 'Upload', '$timeout', function ($scope, Upload, $timeout) { console.log("Hey ho from controller"); $scope.uploadFiles = function (files) { $scope

Multer gridfs storage referencing uploaded file to a new collection

一笑奈何 提交于 2019-12-12 01:19:41
问题 Uploaded file using multer gridfs storage i want to reference it to newly created collection (movies). The fileID i referenced to the uploaded file is not the same with the uploaded file, even with that the movies collection is not saved on to the database. The fileID i referenced to the uploaded file is not the same with the uploaded file, even with that the movies collection is not saved on the database //movie schema const mongoose = require('mongoose'); const Schema = mongoose.Schema;

Syntax issue with using Multer in Node.js

巧了我就是萌 提交于 2019-12-11 21:22:08
问题 i've been using this tutorial : https://medium.com/@mahesh_joshi/reactjs-nodejs-upload-image-how-to-upload-image-using-reactjs-and-nodejs-multer-918dc66d304c To upload a file from React client side to Node.js server side. I'm havng an issue with the POST route given in the tutorial, VS Code shows a syntax error when pasting it. Can anyone re-arrange it? This is the route : router.post("/upload", { upload(req, res, (err) => { console.log("Request ---", req.body); console.log("Request file ---"

Multer Unexpected field, even field names are same

守給你的承諾、 提交于 2019-12-11 18:53:31
问题 I am uploading multiple files from different fields. when i upload file via Postman, Multer fails with Unexpected field error. even though i checked, my field names are exactly same with which i am using in multer. This is my exception: MulterError: Unexpected field at wrappedFileFilter (F:\Node-Installments-Management\node_modules\multer\index.js:40:19) at Busboy.<anonymous> (F:\Node-Installments-Management\node_modules\multer\lib\make-middleware.js:114:7) at Busboy.emit (events.js:182:13)

Nodejs Multer diskStorage not working - why destination targeting temp folder and not uploading

我们两清 提交于 2019-12-11 18:41:37
问题 I am using Multer to upload a profile image and unfortunately not working correctly. This is my code: var express = require("express"); var multer = require('multer'); var app = express(); var storage = multer.diskStorage({ destination: function (req, file, callback) { callback(null, './public/uploads'); }, filename: function (req, file, callback) { callback(null, file.fieldname + '-' + Date.now()); } }); var upload = multer({ storage : storage}).single('avatar'); exports.uploadAvatar =