multer

upload files to remote server using multer sftp in express Node js?

*爱你&永不变心* 提交于 2019-12-01 14:33:56
问题 I'm trying to upload the files to remote server using multer-sftp in node js. since i'm following the official docs npm multer-sftp. Previously i've uploading the files to Amazon S3 instead of remote server. now i want to upload the files to remote server. API: exports.newFileUpload = function(req , res , next){ var storage = sftpStorage({ sftp: { host: 'http://www.port*****es.in/', port: 22, username: 'username', password: 'password' }, destination: function (req, file, cb) { cb(null,

Multer upload files with PM2

强颜欢笑 提交于 2019-12-01 10:31:21
问题 i have a express app and am using multer to uploads files, the problem is when i running the app in the production server with PM2 the multer upload file gave me an error: "Error: ENOENT: no such file or directory, open 'uploads/img.png' at Error (native)" but when i run it with "Debug=projectname:* npm start" its just work fine. note that i already create uploads directory with all the permissions "read and write for anyone". (sorry for my bad english) 回答1: I will try to guess the problem.

Express.js and multer: how to know when the files are all uploaded?

三世轮回 提交于 2019-12-01 05:18:24
I'm using Multer module for file uploads. While it all works ok, there's a warning at the end of their github page, which reads: "WARNING: req.body is fully parsed after file uploads have finished. Accessing req.body prematurely may cause errors." This has got me really worried. I just can't find a way to let the .post middleware know when the file(s) have been uploaded and req.body is ready to use. Here's my code: app.js: app.use(multer({ dest: './uploads/', rename: function (fieldname, filename) { return filename.replace(/\W+/g, '-').toLowerCase() + Date.now(); }, putSingleFilesInArray: true

Express.js and multer: how to know when the files are all uploaded?

一笑奈何 提交于 2019-12-01 03:05:58
问题 I'm using Multer module for file uploads. While it all works ok, there's a warning at the end of their github page, which reads: "WARNING: req.body is fully parsed after file uploads have finished. Accessing req.body prematurely may cause errors." This has got me really worried. I just can't find a way to let the .post middleware know when the file(s) have been uploaded and req.body is ready to use. Here's my code: app.js: app.use(multer({ dest: './uploads/', rename: function (fieldname,

Uploading a file and passing a additional parameter with multer

妖精的绣舞 提交于 2019-11-30 14:34:40
I am using the jQuery Form Plugin and multer to upload files to my server. This works just fine, but I am trying to pass an additional parameter, which will determine where exactly the file will be saved. I have following code, which I would like to extend to behave as stated: HTML <form id="uploadForm" enctype="multipart/form-data" action="/files" method="post"> <input type="file" id="userFile" name="userFile"/> <input type="text" hidden id="savePath" name="savePath" value="path"/> </form> Client JS uploadForm.submit(function() { $(this).ajaxSubmit({ error: function(xhr) { console.log('Error:

Upload multiple file using multer failed [closed]

那年仲夏 提交于 2019-11-30 13:32:07
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 3 years ago . I got empty array doing below function after follow the documentation. var multer = require('multer'); var upload = multer(); router.post('/image', upload.array('photos', 4), function(req, res) { var file = req.files; console.log('======') console.log(file); res.end(); }); <form action="/products

multer configuration with app.use returns TypeError

最后都变了- 提交于 2019-11-30 13:16:56
问题 I'm trying to configure multer in my app.js file (using node.js/express) in order to allow users to upload images. I have the following code in app.js: //various require statements for passport, cookie parser, etc.. var multer = require('multer'); var app = express(); app.use(multer({dest:'./uploads/'})); When I try to run the app I get TypeError: app.use() requires middleware functions I understand that this questions may require some more context with regards to my app so please let me know

Send blob data to node using fetch, multer, express

心已入冬 提交于 2019-11-30 12:55:36
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){ console.log(err); }); } This is my express route, which uses multer: var upload = multer({ dest: _

How to store a file with file extension with multer?

微笑、不失礼 提交于 2019-11-30 12:44:33
问题 Managed to store my files in a folder but they store without the file extension. Does any one know how would I store the file with file extension? 回答1: From the docs: "Multer will not append any file extension for you, your function should return a filename complete with an file extension." Here's how you can add the extension: var multer = require('multer'); var storage = multer.diskStorage({ destination: function (req, file, cb) { cb(null, 'uploads/') }, filename: function (req, file, cb) {

multer - req.file always undefined

喜夏-厌秋 提交于 2019-11-30 11:26:12
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(express.static(path.join(__dirname, 'main'))); app.post('/upload', upload.single('upl'), function (req,