skipper-s3-resizerdeprecated

Streaming file uploads to S3 and resize images

Usage no npm install needed!

<script type="module">
  import skipperS3Resizer from 'https://cdn.skypack.dev/skipper-s3-resizer';
</script>

README

skipper-s3-resizer

This is extended skipper-s3-resizer based on - Original skipper-s3-resize

New features

Adds optional configurations:

  • prefix - S3 object prefix (Default: '')
  • filename - Custom function for naming files to be uploaded (Default: <uuid>.<ext>).
  • stretch - Whether to stretch or cover image (Default: false).

Changed resizing technique:

  • If width and height are not specified, image will be uploaded in original size
  • If only one dimension is specified, downscale (keeps aspect-ratio)
  • If both dimensions are specified

Based on SailsJS Skipper S3 adapter for receiving upstreams with a twist: Images will be resized before uploading using GraphicMagick.

Installation

  1. Make sure you have graphicmagick installed.

  2. Make sure you have skipper itself installed as your body parser. This is the default configuration in Sails as of v0.10.

  3. Run in your console:

  npm install skipper-s3-resizer --save

Usage

  1. In Controller:
  upload: function(req, res) {
    req.file('image').upload({
      adapter: require('skipper-s3-resizer'), // Required
      key: <YOUR_S3_ACCESS_KEY>, // Required
      secret: <YOUR_S3_SECRET_KEY>, // Required
      bucket: <YOUR_S3_BUCKET>, // Required
      prefix: 'prefixed',
      filename: function (base, ext) {
        return sails.shortid.generate().concat(ext);
      },
      resize: {
        stretch: false,
        width: <WIDTH>,
        height: <HEIGHT>
      },
      headers: { 
        'x-amz-acl': 'public-read'
      }
    }, function(err, uploadedFiles) {
      if(err) return res.serverError(err);
        res.ok();
      });
    }

More info about headers:

References

  1. Original skipper-s3-resize
  2. Skipper documentations.