multer

Heroku crash over and over by POST request, multer or nodemailer H=18

社会主义新天地 提交于 2019-12-10 17:26:56
问题 My deployment on Heroku keep crashing on the POST request when I send the mulitpart form. I can't see in the logs if it's on the upload (multer) function, save (mongoose) function or sendMail (nodemailer) function. The only thing I see in the logs is a H18 error: Internal Server. Router.js const express = require("express"); const mongoose = require("mongoose"); const router = express.Router(); const multer = require("multer"); const path = require("path"); const File = require("../models

Retaining image file name and extension after upload in node.js (express) using multer

落爺英雄遲暮 提交于 2019-12-10 15:56:24
问题 <!doctype html> <html> <body> <form action="/upload" method="POST" enctype="multipart/form-data"> <input type='file' name="image"> <br> <input type="submit" value="submit"> </form> </body> </html> var express = require('express'); var router = express.Router(); var multer = require('multer'); var upload = multer({ dest: 'uploads/', filename: function (req, file, cb) { cb(null, file.fieldname + '-' + Date.now()) } }); router.post('/upload', upload.single('image'), function(req, res){ res.send(

How to fix '413 Request Entity Too Large' error in Node.js

浪子不回头ぞ 提交于 2019-12-10 12:11:11
问题 I am attempting to allow users to upload several images to my website which will then get emailed to all users as attachments but I am coming across an error stating the file size is too large. I am using Mailgun to send the mail, Cloudinary to upload/store the images, MongoDB as my database, request.js to request the images, Cloud 9 to develop in, and Node.js/Express as my backend. The user process goes like this: User submits pictures onto the site Pictures are uploaded via Cloudinary and

How to post multipart/form-data from Angular to Nodejs Multer?

ⅰ亾dé卋堺 提交于 2019-12-10 04:10:16
问题 From Angular I want to upload a image as Blob data to nodeJS server. The server uses multer in the backend. The image file is generated by canvas render. I am getting the following error from the server: Error: Multipart: Boundary not found status:500 The following is my code. Please help me to find out the issue. Angular: // blob:Blob; -> it has valid image data. var formData: FormData = new FormData(); formData.append('banner', blob, "my-file.png") this.http.post(url, formData, { headers:

Why is file being corrupted during multipart upload into express running in aws lambda?

只愿长相守 提交于 2019-12-09 10:29:02
问题 Have a SPA with a redux client and an express webapi. One of the use cases is to upload a single file from the browser to the express server. Express is using the multer middleware to decode the file upload and place it into an array on the req object. Everything works as expected when running on localhost. However when the app is deployed to AWS, it does not function as expected. Deployment pushes the express api to an AWS Lambda function, and the redux client static assets are served by

How do i add new field other than multer-gridfs-storage default properties

末鹿安然 提交于 2019-12-08 13:22:22
问题 I wanted to add new fields (objects) other than multer-gridfs-storage default fields but to no avail, the fields i want to add are: Description category Token The default field has something like _id length chunksize uploadDate md5 contentType instead want to add something like _id length chunksize uploadDate md5 contentType description category and the rest And also is there a way to add a thumbnail to file so i don't i have reference my file id to the thumbnail in other collection const

Can't set headers after they are sent node js

感情迁移 提交于 2019-12-08 10:42:33
问题 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 = req.body.name; user.profile.gender = req.body.gender; var files = req.files.file; if (files){ if (files.length > 0){

Multer, Node, EACCES error on C9.io

喜夏-厌秋 提交于 2019-12-08 04:28:35
问题 Hiya all thanks in advance for any help you can provide. I am using C9.io, node, express, multer, gridfs-stream. And Im getting: /home/ubuntu/workspace/node_modules/multer/index.js:25 mkdirp(dest, function(err) { if (err) throw err; }); Error: EACCES, mkdir '/uploads' I run the server.js script and that is the error that I get. I believe is something to do with permissions but i have tried chown the public folder and chmod ax, you guys have any other suggestions as to what to do?. Still get

Should not allow file upload if anyone changes extension from exe to png via multer in node js application

眉间皱痕 提交于 2019-12-07 12:08:29
问题 I'm uploading file using multer in my nodejs (express js) application which is working fine. I have put a mime type check there also to allow only png files but if I change the ext of the uploaded file from abc.exe to abc.png it also gets uploaded which is wrong. here is my code. var multer = require('multer'); var imagefolder = __base + 'public/complaintimages/'; var diskstorage = multer.diskStorage({ destination: function (req, file, cb) { if (common.ImageMimeTypes.indexOf(file.mimetype) <

Sending canvas.toDataURL() as FormData

你说的曾经没有我的故事 提交于 2019-12-07 08:17:40
问题 I am trying to use html2canvas to render a DOM element as a .png image, which I then want to upload to the server. Here is my code: import React, { Component, PropTypes } from 'react'; import html2canvas from 'html2canvas'; import axios from 'axios'; const sendScreenshot = (img) => { const config = { headers: { 'content-type': 'multipart/form-data' } } let data = new FormData(); data.append('screenshot', img); return axios.post('/api/upload', data) } export default class Export extends