GithubHelp home page GithubHelp logo

diasalvatore / node-s3-uploader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from turistforeningen/node-s3-uploader

0.0 2.0 0.0 24 MB

Flexible and efficient resize, rename, and upload images to Amazon S3 disk storage. Uses the official AWS Node SDK and ImageMagick for image processing. Support for multiple versions version targets.

License: MIT License

CoffeeScript 97.06% Shell 2.94%

node-s3-uploader's Introduction

AWS S3 Image Uploader

Build status NPM downloads NPM version Node version Dependency status

Flexible and efficient resize, rename, and upload images to Amazon S3 disk storage. Uses the official AWS Node SDK and GM for image processing.

Join the chat at https://gitter.im/Turistforeningen/node-s3-uploader

Install

npm install s3-uploader --save

Requirements

  • Node.JS >= v0.10
  • imagemagic
  • AWS credentials environment variables
    • AWS_ACCESS_KEY_ID
    • AWS_SECRET_ACCESS_KEY

API

var Upload = require('s3-uploader');

new Upload(string awsBucketName, object opts)

  • string awsBucketName - name of Amazon S3 bucket
  • object opts - global upload options
    • number resizeQuality - thumbnail resize quallity (default 70)

    • boolean returnExif - return exif data for original image (default false)

    • string tmpDir - directory to store temporary files (default os.tmpdir())

    • number workers - number of async workers (default 1)

    • string url - custom public url (default build from region and awsBucketName)

    • object aws - AWS SDK configuration optsion

      • string region - region for you bucket (default us-east-1)
      • string path - path within your bucket (default "")
      • string acl - default ACL for uploded images (default privat)
      • string accessKeyId - AWS access key ID override
      • string secretAccessKey - AWS secret access key override

The aws object is passed directly to aws-sdk. You can add any of these options in order to fine tune the connection โ€“ if you know what you are doing.

  • object[] versions - versions to upload to S3
    • boolean original - set this to true to save the original image
    • string suffix - this is appended to the file name (default "")
    • number quality - resized image quality (default resizeQuality)
    • number maxWidth - max width for resized image
    • number maxHeight - max height for resized image

Example

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
  }]
});

#upload(string src, object opts, function cb)

  • string src - absolute path to source image to upload

  • object opts - upload config options

    • string awsPath - local override for opts.aws.path
  • function cb - callback function (Error err, object[] versions, object meta)

    • Error err - null if everything went fine
    • object[] versions - original and resized images with path/location
    • object meta - metadata for original image

Example

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);
    }
  }
});

Algorithm

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.

node-s3-uploader's People

Contributors

gitter-badger avatar starefossen avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.