Documentation for [email protected]
can be found here.
Flexible and efficient image resize, rename, and upload to Amazon S3 disk storage. Uses the official AWS Node SDK, and im-resize and im-metadata for image processing.
All changes are documentated on the releases page. Changes for latest release can be found here.
npm install s3-uploader --save
- Node.JS >= v4.0.0
- ImageMagic >= v6.8
var Upload = require('s3-uploader');
- string
awsBucketName
- name of Amazon S3 bucket - object
opts
- global upload options-
object
cleanup
- boolean
original
- remove original image after successful upload (default:false
) - boolean
versions
- remove thumbnail versions after sucessful upload (default:false
)
- boolean
-
boolean
returnExif
- return exif data for original image (defaultfalse
) -
string
url
- custom public url (default build fromregion
andawsBucketName
) -
object
aws
- see note- string
region
- region for you bucket (defaultus-east-1
) - string
path
- path within your bucket (default""
) - string
acl
- default ACL for uploaded images (defaultprivate
) - string
accessKeyId
- AWS access key ID override - string
secretAccessKey
- AWS secret access key override
- string
-
object
resize
- string
path
- local directory for resized images (default: same as original image) - string
prefix
- local file name prefix for resized images (default:""
) - integer
quality
- default quality for resized images (default:70
)
- string
-
object[]
versions
- string
suffix
- image file name suffix (default""
) - number
quality
- image resize quality - string
format
- force output image file format (defaultformat of original image
) - number
maxWidth
- max width for resized image - number
maxHeight
- max height for resized image - string
aspect
- force aspect ratio for resized image (example:4:3
- string
background
- set background for transparent images (example:red
) - boolean
flatten
- flatten backgrund for transparent images - string
awsImageAcl
- access control for AWS S3 upload (example:private
) - number
awsImageExpires
- addExpires
header to image version - number
awsImageMaxAge
- addCache-Control: max-age
header to image version
- string
-
object
original
- string
awsImageAcl
- access control for AWS S3 upload (example:private
) - number
awsImageExpires
- addExpires
header to image version - number
awsImageMaxAge
- addCache-Control: max-age
header to image version
- string
-
function
randomPath
- custom random path function
-
The
aws
object is passed directly toaws-sdk
. You can add any of these options in order to fine tune the connection – if you know what you are doing.
var client = new Upload('my_s3_bucket', {
aws: {
path: 'images/',
region: 'us-east-1',
acl: 'public-read'
},
cleanup: {
versions: true,
original: false
},
original: {
awsImageAcl: 'private'
},
versions: [{
maxHeight: 1040,
maxWidth: 1040,
format: 'jpg',
suffix: '-large',
quality: 80,
awsImageExpires: 31536000,
awsImageMaxAge: 31536000
},{
maxWidth: 780,
aspect: '3:2!h',
suffix: '-medium'
},{
maxWidth: 320,
aspect: '16:9!h',
suffix: '-small'
},{
maxHeight: 100,
aspect: '1:1',
format: 'png',
suffix: '-thumb1'
},{
maxHeight: 250,
maxWidth: 250,
aspect: '1:1',
suffix: '-thumb2'
}]
});
-
string
src
- path to the image you want to upload -
object
opts
- string
awsPath
- override the path on AWS set throughopts.aws.path
- string
path
- set absolute path for uploaded image (disables random path)
- string
-
function
cb
- callback function (Errorerr
, object[]versions
, objectmeta
)- Error
err
-null
if everything went fine - object[]
versions
- original and resized images with path/location - object
meta
- metadata for original image
- Error
client.upload('/some/image.jpg', {}, function(err, versions, meta) {
if (err) { throw err; }
versions.forEach(function(image) {
console.log(image.width, image.height, image.url);
// 1024 760 https://my-bucket.s3.amazonaws.com/path/110ec58a-a0f2-4ac4-8393-c866d813b8d1.jpg
});
});
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.
Individuals making significant and valuable contributions are made Collaborators and given commit-access to the project. These individuals are identified by the existing Collaborators and their addition as Collaborators is discussed as a pull request to this project's README.md.
Note: If you make a significant contribution and are not considered for commit-access log an issue or contact one of the Collaborators directly.
- Hans Kristian Flaatten: @Starefossen, @Starefossen
- Anthony Ringoet: @anthonyringoet, @anthonyringoet