alexandre-io / multer-imager Goto Github PK
View Code? Open in Web Editor NEWImager multer storage engine permit to resize and upload an image to AWS S3
License: MIT License
Imager multer storage engine permit to resize and upload an image to AWS S3
License: MIT License
const multerOptions = multer({
storage: imager({
accessKeyId: process.env.AWS_ACCESS,
secretAccessKey: process.env.AWS_SECRET_KEY,
bucket: process.env.AWS_BUCKET,
region: process.env.AWSregion,
/*acl: 'public-read',
// Auto detect contet type
contentType: multerS3.AUTO_CONTENT_TYPE, */
dirname: 'images',
filename: function(req, file, cb) {
const extension = file.mimetype.split('/')[1]; // gets the extension
const area = 'test_';
const fileName = `${area}${uuid.v4()}.${extension}`;
console.log('file name is ', fileName);
cb(null, fileName);
},
gm: {
pool: 5,
format: 'png',
scale: {
width: 200,
height: 200,
type: 'contain',
},
crop: {
width: 200,
height: 200,
x: 0,
y: 0,
},
rotate: 'auto',
},
**// This part is not being executed.**
fileFilter(req, file, next) {
const isPhoto = file.mimetype.startsWith('image/');
console.log(req.files);
if (isPhoto) {
next(null, true); // null for error means it worked and it is fine to continue to next()
console.log(isPhoto);
} else {
next({ message: 'Fotos: Tipo de arquivo não suportado!' }, false); // with error
}
},
s3: {
Metadata: {
ACL: 'public-read',
customkey: 'data',
},
},
}),
});
exports.upload = multer(multerOptions).array('photos', 5);
Files are going to S3 with the right name but at zero bytes, the commented part is not getting executed either. Ideas?
Branch | Build failing 🚨 |
---|---|
Dependency | mime |
Current Version | 2.0.3 |
Type | dependency |
This version is covered by your current version range and after updating it in your project the build failed.
mime is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.
The new version differs by 15 commits ahead by 15, behind by 1.
25141e4
chore(release): 2.0.5
f14ccb6
fix: ES5 support (back to node v0.4)
ab5238a
2.0.4
b94c4ab
changelog
175cd7c
mime-score -> dev dependency
8cc0f4f
Remove vestigial getScore() method
852b042
Merge branch 'master' of github.com:broofa/node-mime
f548916
use mime-score module for resolving extension contentions. Fixes #182
34b5c6b
Link to 1.x version of docs
6e7b9bb
Merge pull request #177 from JuanjoSalvador/patch-1
18cad2e
Fixed markdown mistakes
786a9bf
readme_js.md
453725b
Correct wzrd.in usage
36de668
2.0.3
1dcef8a
changelog
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
☝️ Greenkeeper’s updated Terms of Service will come into effect on April 6th, 2018.
Branch | Build failing 🚨 |
---|---|
Dependency | s3rver |
Current Version | 2.2.1 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
s3rver is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
Fixes:
Tooling:
The new version differs by 25 commits.
c51f5e8
Publish a 2.2.2 patch version
3c0843d
chore(deps): update dependency aws-sdk to v2.210.0
2c663ca
Merge pull request #188 from jamhall/fix-s3event
535f717
fix(s3Event): Size and MD5 missing in certain event types
c28f8cc
Merge pull request #187 from jamhall/fix-listobjects-istruncated
bc79afb
Merge pull request #186 from jamhall/fix-listobjects-bucket-name
d0b74a8
fix(listObjects): Include correct IsTruncated value in response
325ca7f
fix(listObjects): Include bucket name in XML response
d69913a
chore(deps): update dependency aws-sdk to v2.209.0
1e152e2
Merge pull request #182 from jamhall/n1ru4l-patch-1
84187d2
Merge pull request #177 from jamhall/co-mocha
fc7a12f
refactor(test): Use co-mocha for async tests
b887fb0
Use getter instead fo inline cast
8739779
Merge pull request #183 from n1ru4l/upstream/n1ru4l-patch-1
3283b62
Cast to date before formatting
There are 25 commits in total.
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:
.travis.yml
package.json
files, so that was left aloneIf you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.
Greenkeeper has checked the engines
key in any package.json
file, the .nvmrc
file, and the .travis.yml
file, if present.
engines
was only updated if it defined a single version, not a range..nvmrc
was updated to Node.js 10.travis.yml
was only changed if there was a root-level node_js
that didn’t already include Node.js 10, such as node
or lts/*
. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.For many simpler .travis.yml
configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
I use
` router.post('/demos/create', upload.array('demoImage', 1), function(req,res){
//asdada
}`
How to logg if multer sending a error?
I don't understand how to use options
and ACL permission
. Here, in this example, options are not working (image is uploaded, but nothing is resized) and ACL doesn't set public-read for the uploaded file. Any idea why? Thanks.
var avatar = multer({
storage: imager(
{
accessKeyId: process.env.AWSAccessKeyId,
secretAccessKey: process.env.AWSSecretKey,
region: process.env.AWSregion,
bucket: 'my-bucket',
dirname: 'images',
filename: function (req, file, cb) {
cb(null, req.user._id + ".png");
},
gm: {
pool: 5,
format: 'png',
scale: {
width: 200,
height: 200,
type: 'contain'
},
crop: {
width: 200,
height: 200,
x: 0,
y: 0
},
rotate: 'auto'
},
s3 : {
Metadata: {
"x-amz-acl": "public-read"
}
}
})
});
I think nothing is transmitted, neither gm options, nor s3 Metadata.
Is there any way to set the Content-Type when uploading the file?
2.2.6
to 2.2.7
.This version is covered by your current version range and after updating it in your project the build failed.
s3rver is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
Fixes:
Tooling:
The new version differs by 40 commits.
85d1d1d
Increment version to v2.2.7
2594675
chore(deps): update dependency aws-sdk to v2.369.0
2ec958a
Merge pull request #347 from justinmchase/fix/346-handle-empty-acrh
80ad50c
Merge pull request #325 from jamhall/error-exit-status
39dbf72
chore(deps): update dependency aws-sdk to v2.368.0
23b752a
Refactor for clarity based on CR feedback
03ae68c
chore(deps): update dependency prettier to v1.15.3
f1fbe9c
Fix prettier errors
597f29e
Handle the case where the access-control-request-header is not provided
02389b9
chore(deps): update dependency aws-sdk to v2.362.0
325e841
chore(deps): update dependency aws-sdk to v2.361.0
4ece647
chore(deps): update dependency aws-sdk to v2.358.0
98a0646
chore(deps): update dependency aws-sdk to v2.354.0
7eb0f67
chore(deps): update dependency aws-sdk to v2.353.0
7cc8527
chore(deps): update dependency eslint-config-prettier to v3.3.0
There are 40 commits in total.
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Branch | Build failing 🚨 |
---|---|
Dependency | gm |
Current Version | 1.23.0 |
Type | dependency |
This version is covered by your current version range and after updating it in your project the build failed.
gm is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.
The new version differs by 7 commits.
0286f47
release 1.23.1
e8cfed6
add nsp checks
2507d59
get tests passing on OSX
442d081
Update package.json
46ceadd
deps: Allow [email protected] because of security issue
c6a6c5a
Merge pull request #563 from aheckmann/globals
74473c2
tests; remove global leaks
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
I'm still hoping / looking for for documentation or examples for using the Graphics Magick options.
The sample code works great--
gm: {
width: 200,
height: 200,
options: '!',
format: 'png'
},
But I'd like to be able to use things like crop or scale, like this:
gm: {
crop: {
x: 100, y:100, width:200, height:200
},
options: '!',
format: 'png' // Default: jpg
},
But I don't know how I should configure these options -- and I don't know if they are included or made accessible by multer-imager. So far they just seem to get ignored completely. Should they be structured in an object format like this? Is there somewhere this id documented? The main graphics magick documentation explains the CLI version, and the javascript -based version-- but doesn't cover how to structure these options.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.