Flexible and efficient resize, rename, and upload images to Amazon S3 disk storage. Uses the official AWS Node SDK and GM for image processing.
npm install s3-uploader --save
- Node.JS >= v0.10
- imagemagic
- AWS credentials environment variables
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY
var Upload = require('s3-uploader');stringawsBucketName - name of Amazon S3 bucketobjectopts - global upload optionsstringawsBuckeRegion - region for you bucket; default "us-east-1"stringawsBucketPath - path within your bucket (ex. "/images")stringawsBucketAcl - default ACL for uploded imagesnumberawsMaxRetries - max number of retries; default 3numberawsHttpTimeout - inactive time (ms) beofre timing out; default 10000numberresizeQuality - default resize quallitybooleanreturnExif - return exif data for original imagestringtmpDir - directory to store temporary filesnumberasyncLimit - limit number of async workersobject[]versions - versions to upload to S3booleanoriginal - if this is the original imagestringsuffix - this is appended to the file namenumberquality - resized image qualitynumbermaxWidth - max width for resized imagenumbermaxHeight - max height for resized image
var client = new Upload('my_s3_bucket', {
awsBucketRegion: 'us-east-1',
awsBucketPath: 'images/',
awsBucketAcl: 'public-read',
versions: [{
original: true
},{
suffix: '-large',
quality: 80,
maxHeight: 1040,
maxWidth: 1040,
},{
suffix: '-medium',
maxHeight: 780,
maxWidth: 780
},{
suffix: '-small',
maxHeight: 320,
maxWidth: 320
}]
});stringsrc - absolute path to source image to uploadobjectopts - local upload config options (overwrites global config)functioncb - callback function (Errorerr,object[]versions,objectmeta)Errorerr -nullif everything went fineobject[]versions - original and resized images with path/locationobjectmeta - metadata for original image
client.upload('/some/file/path.jpg', {}, function(err, images, meta) {
if (err) {
console.error(err);
} else {
for (var i = 0; i < images.length; i++) {
console.log('Thumbnail with width %i, height %i, at %s', images[i].width, images[i].height, images[i].url);
}
}
});A
+-- B
`-- C
`-- D
`-- E
Where A is the original image uploaded by the user. An mpc image is created, B,
which is used to crate the thumbnails C, D, and E.

