multer-s3 | multer storage engine for amazon s3 | Cloud Storage library
kandi X-RAY | multer-s3 Summary
kandi X-RAY | multer-s3 Summary
Streaming multer storage engine for AWS S3. This project is mostly an integration piece for existing code samples from Multer's storage engine documentation with s3fs as the substitution piece for file system. Existing solutions I found required buffering the multipart uploads into the actual filesystem which is difficult to scale.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of multer-s3
multer-s3 Key Features
multer-s3 Examples and Code Snippets
const express = require('express');
const bodyParser = require('body-parser');
const AWS = require('aws-sdk');
const multer = require('multer')
Community Discussions
Trending Discussions on multer-s3
QUESTION
I'm trying to resize image to 3 type: large.jpg, medium.webp, small.webp and I'm using multer-s3-transform
but all result image contentType is 'image/jpeg' image
my original image is jpg and I want it to transform to webp. Can someone help me, here is my code:
...ANSWER
Answered 2021-May-27 at 08:14So I solve my problem by using multer and sharp
UploadController:
QUESTION
Attempting to deploy to heroku for the first time, and i've been getting this sasserror which causes the build to fail and reject.
Steps taken for resolution
- Delete node sass and node modules / reinstall / push to master repo
- Adjust import path to @import './scss/_variables.scss';
- Delete the first import to check if that file was the issue
- Update node to support node-sass compatibility
Question
- Create React App has webpack built internally, do i need to add my own webpack config for sass-loaders, css-loaders, style-loaders?
- i've only ever used webpack with rails before, if i do need webpack, for my output params, what should replace the "bundle.js" i get from rails?
Terminal response
...ANSWER
Answered 2021-May-25 at 19:42Try this:
https://create-react-app.dev/docs/adding-a-sass-stylesheet
f you set SASS_PATH=node_modules:src
, this will allow you to do imports like
QUESTION
I am working build an OTT platform but facing issue on Uploading large file to server.
I have tried doing it with multer to store the file in temp folder and use aws-sdk s3.upload
.
It works fine with small file size, But if I tries to Upload Large file, it return
Network Error or Error 413 request entity too large
Following Error 413 - I have changed nginx.config (client_max_body_size 0;
)
// 0 is for unlimited
but still no change. I have also tried doing it with multer-s3 but still no success. Later I tried doing it with busboy but still I am facing same issue. Here I am attaching my code where I am using busboy In ReactJs I am using Axios Please help
server.js
...ANSWER
Answered 2021-May-02 at 16:22I suggest you to use presigned S3 uploads link. In that case the server is responsible to return presigned upload link only and, from client code, just upload a file directly to AWS S3.
QUESTION
I'm trying to do the following in Node.js using express router, Multer-S3, Multer, AWS and Mongodb.
I want to: 1: Check if filetype is image, price is number etc (some kind of quality check) 2: If above true, upload image to S3 to get Image url 3: If Image Url was generated, upload to Mongodb, including the generated image url..
Trying with below code but can only get one of these to work at same time..
...ANSWER
Answered 2021-Mar-16 at 06:49There are 2 ways to do this, either you can use only multer
or multer-s3
.
For simplicity, I will show you the way using only multer
.
Flow of processing as follow:
- Multer process and save to local
- You read from local, and upload to s3 using s3 SDK (You should explore how to remove the file after upload as well, but I wont clutter you with this logic here)
- If upload is successful, you retrieve the URL and pass it to your MongoDB.
QUESTION
Hi i need to upload multiple images at a time on s3.
Currently i am using express-fileupload
to upload single image on AWS, and i want to use same approach to make it upload multiple files to s3 and update images array with urls on mongodb.
My schema property:
...ANSWER
Answered 2021-Jan-27 at 14:08This approach might be different for you but that is how I was able to resolve the same issue.
First you'll need
- Multer
- multer-s3
- aws-sdk
I made a FileUpload class that handles both single and multi-upload (I also needed to be able to upload pdf and video files) and this is the code in my constructor, note that I also specified the s3-bucket in question from aws.
QUESTION
require("dotenv").config();
const AWS = require("aws-sdk");
const multer = require("multer");
const multerS3 = require("multer-s3");
const uuid = require("uuid").v4;
const path = require("path");
const s3 = new AWS.S3({
accessKeyId: process.env.AWS_S3_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_S3_SECRET_ACCESS_KEY
});
const upload = multer({
storage: multerS3({
s3: s3,
Bucket: process.env.AWS_S3_BUCKET_NAME,
ACL: "public-read",
metadata: (req, file, cd) => {
cd(null, { fieldName: file.fieldname });
},
key: (req, file, cb) => {
const ext = path.extname(file.originalname);
const uniqueName = `${uuid()}${ext}`;
cb(null, uniqueName);
},
}),
});
module.exports = {
upload
}
router.post("/photo-upload", upload.array('photos'), (req, res) => {
return res.status(200).send({
success: true,
result: 'Images Uploaded',
});
});
...ANSWER
Answered 2021-Jan-24 at 10:54I would suggest you maybe consider using multer and multerS3 libraries, this would look as follows.
fileUpload.js
QUESTION
I am trying to generate presigned url for my s3 bucket. After that when i copy paste the generated url in browser i get this error
...ANSWER
Answered 2021-Jan-17 at 17:44KEY in bucketParms should be the key of the s3 object.
Signed Url for downloading an object from S3
Bucket: test-events ObjectKey: myfolder/test.json
QUESTION
I know this question has been asked a lot, I've tried pretty much every answer to try to get this running but I keep getting undefined for req.file.
Code below:
services.imageUpload.js
...ANSWER
Answered 2021-Jan-11 at 12:57In your index.js
you can bring
QUESTION
I have a form in my express application for users to enter some text, and also upload 1-3 photos. I'm handling the file uploads to my S3 bucket with multer, and I'm validating the rest of the form with express-validator
.
This makes my POST route look like:
...ANSWER
Answered 2020-Dec-20 at 07:25Quick Fixes:
- call
singleUpload
in middleware, and here you are uploading single file usingupload.single()
, so you need to removemultiple
attribute from view file tag, if you want to upload multiple file then useupload.array('field name', total count of files)
QUESTION
I'm uploading images from a form to my S3 bucket. When the form is submitted, it creates a new mongoDB object. I'm using key: function (req, file, cb) {cb(null, Date.now().toString())},
to give the uploads unique names. My issue is, when I'm saving the new mongoDB object, I'm not sure how to reference the unique S3 key.
I admit this might be a dumb question, but I'm not very experienced with mongoDB/mongoose and this is my first time ever working with S3.
I would greatly appreciate any advice or recommendations
...ANSWER
Answered 2020-Dec-11 at 00:51I'm not a pro on this but i can think in one solution:
I see you handle the request first in the upload, so there you can save on the request the value of the Key, and not use directly the Date.now() on the name of the image when you create the file
So you should do: req.imageName = new Date.now().toString() And in the name change that creation of the name with req.imageName
Then in the next controller handling the request, you have access to the name on the object "req" provided to the function.
NOTE: new Date.now() IS NOT a good unique key if you have concurrent request for different clients, you have a high probability of getting the same number if you have too much requests at the same time.
NOTE 2: I can think on uuid for better unique keys, i don't know too much about others librarys that can solve that problem.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install multer-s3
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page