multer

Type of object received during file upload using @UploadFile

耗尽温柔 提交于 2019-12-02 17:54:25
问题 In the REST API below, what is the type of file object that is received. @Post('/:folderId/documents/:fileName') @UseInterceptors(FileInterceptor('file')) @ApiConsumes('multipart/form-data') @ApiImplicitParam({ name: 'folderId', description: ' Folder Id' }) @ApiImplicitParam({ name: 'fileName', description: ' File Name' }) @ApiImplicitFile({ name: 'file', required: true, description: 'PDF File' }) async uploadFile(@UploadedFile() file, @Param() folderId, @Param() fileName) { /** * I need to

Type of object received during file upload using @UploadFile

孤街醉人 提交于 2019-12-02 12:25:56
In the REST API below, what is the type of file object that is received. @Post('/:folderId/documents/:fileName') @UseInterceptors(FileInterceptor('file')) @ApiConsumes('multipart/form-data') @ApiImplicitParam({ name: 'folderId', description: ' Folder Id' }) @ApiImplicitParam({ name: 'fileName', description: ' File Name' }) @ApiImplicitFile({ name: 'file', required: true, description: 'PDF File' }) async uploadFile(@UploadedFile() file, @Param() folderId, @Param() fileName) { /** * I need to know the type of file object (first argument) of uploadFile */ this.folderService.uploadFile(file,

node js multer file upload not working. req.file and req.files always undefined

£可爱£侵袭症+ 提交于 2019-12-02 09:50:52
I am trying to upload a file to my server, but req.file and req.files is always undefined on my POST REST endpoint. The content I'm trying to upload is a ".dat" file, and I am expecting a json response. Here's my code: Server side: var express = require('express'); var multer = require('multer') var upload = multer({ dest: 'uploads/' }) var app = express() app.post('/creoUpload', upload.single('uploadFileField'), function(req, res, next) { console.log("req.file = ",JSON.stringify(req.file)); //is undefined console.log("req.files = ",JSON.stringify(req.files)); //also undefined }); Client Side:

How to fix 'TypeError: Cannot read property 'path' of undefined' in Nodejs(Multer)

荒凉一梦 提交于 2019-12-02 08:17:10
I am trying to upload the file but there is 'TypeError: Cannot read property 'path' of undefined'. Is there any way to solve this? exports.postimport = function (req,res) { var storage = multer.diskStorage({ destination: function(req, file, cb) { cb(null, 'uploads'); }, filename: function(req, file, cb) { cb(null, file.originalname); } }); var upload = multer({ storage: storage, }).single('sheet'); upload(req, res, function(err) { if (err) { res.send(err) } else { console.log(req.file.path); } }); } The reason you might be getting path of undefined may be that your destination directory (i.e

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

♀尐吖头ヾ 提交于 2019-12-02 04:50:37
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, data) { if (err) throw err; console.log(data); needle.post(server2 + "/post_img", { data: data, name : "test.jpg" }, function(result) { console.log(result); res.send("ok"); }); }); }); This part seems to be working as I could be writing the data in

how to copy files to remote server using scp2 in node js?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 21:41:02
I want to copy the files from local server to remote server in Node js using scp2 package. First of all.. Files uploaded to local server using multer after that copy or move that files to remote server. My Code: exports.newFileUpload = function(req , res , next){ var storage = multer.diskStorage({ //multers disk storage settings destination: function (req, file, cb) { cb(null, 'uploads/'); }, filename: function (req, file, cb) { var datetimestamp = Date.now(); cb(null, datetimestamp+ '-' +file.originalname); } }); var upload = multer({ storage: storage, limits: { fieldSize: 25 * 1024 * 1024 }}

How to send data along with file in http POST (angularjs + expressjs)?

微笑、不失礼 提交于 2019-12-01 20:52:01
问题 Situation I implemented file uploading. Front-end code is taken from popular tutorial. I send POST in service: myApp.service('fileUpload', ['$http', function ($http) { this.uploadFileToUrl = function(file, uploadUrl){ var fd = new FormData(); fd.append('file', file); $http.post(uploadUrl, fd, { transformRequest: angular.identity, headers: {'Content-Type': undefined} }) .success(function(){ }) .error(function(){ }); } }]); Typical multer usage in back-end: exports.postFile = function (req, res

How to send data along with file in http POST (angularjs + expressjs)?

笑着哭i 提交于 2019-12-01 18:30:55
Situation I implemented file uploading. Front-end code is taken from popular tutorial . I send POST in service: myApp.service('fileUpload', ['$http', function ($http) { this.uploadFileToUrl = function(file, uploadUrl){ var fd = new FormData(); fd.append('file', file); $http.post(uploadUrl, fd, { transformRequest: angular.identity, headers: {'Content-Type': undefined} }) .success(function(){ }) .error(function(){ }); } }]); Typical multer usage in back-end: exports.postFile = function (req, res) { var storage = multer.diskStorage({ //multers disk storage settings destination: function (req,

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

对着背影说爱祢 提交于 2019-12-01 15:46:45
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, 'images/') }, filename: function (req, file, cb) { cb(null, file.fieldname + '-' + Date.now()) } }) var

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

北城余情 提交于 2019-12-01 15:33:56
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, './public/uploads/') }, limits:{ files: 1, fileSize: 1024 * 1024 }, filename: function (req, file, cb) { var