• Stars
    star
    241
  • Rank 167,643 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 10 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

AWS S3 Image Uploader

Documentation for [email protected] can be found here.

Build status Codacy grade Codacy coverage NPM downloads NPM version Node version Dependency status Join the chat

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.

Overview of image upload to AWS S3

Changelog

All changes are documentated on the releases page. Changes for latest release can be found here.

Install

npm install s3-uploader --save

Requirements

  • Node.JS >= v4.0.0
  • ImageMagic >= v6.8

API

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

new Upload(string awsBucketName, object opts)

  • 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 returnExif - return exif data for original image (default false)

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

    • object aws - see note

      • string region - region for you bucket (default us-east-1)
      • string path - path within your bucket (default "")
      • string acl - default ACL for uploaded images (default private)
      • string accessKeyId - AWS access key ID override
      • string secretAccessKey - AWS secret access key override
    • 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)
    • object[] versions

      • string suffix - image file name suffix (default "")
      • number quality - image resize quality
      • string format - force output image file format (default format 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 - add Expires header to image version
      • number awsImageMaxAge - add Cache-Control: max-age header to image version
    • object original

      • string awsImageAcl - access control for AWS S3 upload (example: private)
      • number awsImageExpires - add Expires header to image version
      • number awsImageMaxAge - add Cache-Control: max-age header to image version
    • function randomPath - custom random path function

AWS note

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.

Example

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

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

  • string src - path to the image you want to upload

  • object opts

    • string awsPath - override the path on AWS set through opts.aws.path
    • string path - set absolute path for uploaded image (disables random 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/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
  });
});

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.

Collaborators

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.

MIT License

More Repositories

1

leaflet-routing

Leaflet.Routing is a routing controller for the popular Leaflet mapping framework. The module provides an intuitive interface for routing paths between waypoints using any user specified routing service.
JavaScript
259
star
2

node-mongo-querystring

Query builder for accepting URL query parameters into your MongoDB queries. Safe and feature rich. Supports most of MongoDB's query operators such as $eq, $gt, $lt, $ne, $in, $nin, $exists, $regex, geospatial queries such as bbox and near, as well as your own custom query business logic!
JavaScript
100
star
3

sentry

Production ready Sentry configuration for Docker Compose
Python
36
star
4

node-aspectratio

Image aspect ratio calculation utility
JavaScript
20
star
5

node-im-resize

Efficient image resize with multiple versions support
JavaScript
20
star
6

dms2dec.js

Convert GPS degrees, minutes, seconds coordinates to decimal value. Useful for parsing PGS exif tags in geotagged images, Google Maps, and Open Street Map (SOM).
JavaScript
18
star
7

Jotunheimr

Microservice for processing images and uploading them to a designated bucket on AWS S3
JavaScript
13
star
8

node-ga-report

Unofficial NodeJS wrapper for the Google Analytics Core Reporting API
CoffeeScript
10
star
9

node-jfum

Minimal jQuery File Upload Middleware for Express 4.x
JavaScript
10
star
10

Geoserver

In-house Geoserver written in Node.JS
CoffeeScript
10
star
11

docker-paas

Docker Platform as a Service
Shell
6
star
12

Turadmin

Publication and administration tool for trips and places on UT.no and Nasjonal Turbase
JavaScript
6
star
13

jQuery.Hashtag

Open Source jQuery plugin for binding functions to URL hash-tags with support for regular expressions. This makes it super easy to make dynamic and cool looking pages without any need for backend programming languages.
CoffeeScript
6
star
14

status

System Status Overview
JavaScript
5
star
15

dockercloud-haproxy-letsencrypt

Shell
4
star
16

node-geoutil

Geographic formulas and geospatial transformations for Node.JS applications
CoffeeScript
4
star
17

node-librato

Librato client for Node
CoffeeScript
4
star
18

wercker-npm-publish

Publish NPM packages through Wrecker CI
Shell
4
star
19

node-vagrant-template

Vagrant development environment template for your brand new NodeJS projects
CoffeeScript
4
star
20

docker-pgrouting-n50

🐘 🚀 Docker Image with PostgreSQL, PostGIS, pgRouting and N50 data from Kartverket installed
PLpgSQL
3
star
21

Raido

Raidō; a microservice for shortest path routing on Norwegian waymerked trails
JavaScript
3
star
22

jQuery.SSR

Search Norwegian Mapping Authority's Sentralt Stedsnavnsregister (SSR) with jQuery
JavaScript
3
star
23

node-im-metadata

Retrieve image metadata using ImageMagick's identify command
JavaScript
3
star
24

ubuntu-haproxy

Test setup for Haproxy on Ubuntu with multiple vhosts with ssl
PHP
3
star
25

area-drawing

A very simple polygon drawing tool. The utility is used internally to draw up new area classifications in the norwegian mountains. The tools is group based enabling users to only *their* areas while they can view all the rest normally.
JavaScript
3
star
26

hyttebooking

Studentprosjekt for utvikle en bookingløsning for DNT sine hytter
JavaScript
2
star
27

node-dnt-api

Node.JS client for communicating with Turistforeningen's API
CoffeeScript
2
star
28

Hytteadmin

Publication and administration tool for cabins on UT.no and Nasjonal Turbase
JavaScript
2
star
29

hipache

Docker Compose Configuration for Hipache
2
star
30

node-postgres-objectid

Add MongoDB ObjectID to your Postgres rows via a mapping table using NodeJS
CoffeeScript
2
star
31

turistforeningen.github.io

A listing of open source efforts at Turistforeningen on GitHub
HTML
2
star
32

docker-ruby-iojs

Docker Image with Ruby and io.js installed
Shell
1
star
33

Skadi

Skaði; a semantic cors proxy for the Fotoware / Fotoweb REST API
JavaScript
1
star
34

opprop-scraper

Screen scraper for opprop.net
Ruby
1
star
35

dntung-jubileumsfeiring

21. - 22. juni utvider DNT ung døgnet til 25 timer for å feire sin egen 25-årsdag. Hver eneste av disse 25 timene vil en ny DNT ung-aktivitet starte rundt omkring i landet.
JavaScript
1
star
36

Njordr

Njörðr is a browser for Skaði – Fotoweb API adapter
JavaScript
1
star
37

n50-routing-example

Example repository for shortest path routing on Kartverket N50 data
HTML
1
star
38

docker-proxy

Reverse proxy for Docker containers
Shell
1
star
39

docker-stress

Docker image for buaazp/stress
1
star
40

Verdandi

sjekkut-api (verdandi)
JavaScript
1
star
41

librato

Quick and dirty metrics-collecter for librato
Python
1
star
42

hytteadmin_old

R&D management and publishing tool for cabins in Norwegian Trekking Database
CSS
1
star
43

server-config

Ubuntu server configuration files
1
star
44

Vor

Vör is the norse god of wisdom
JavaScript
1
star
45

wercker-deploy-dotcloud

dotCloud deploy step for wercker. Deploy the code to your dotCloud application
Shell
1
star
46

node-dnt-connect

Node.JS library for DNT's single sign on service DNT Connect
JavaScript
1
star
47

docker-paas-iojs-example

io.js example application for Docker PaaS
JavaScript
1
star
48

presentations

Presentations held by the Technology and Development Department in the Norwegian Trekking Association. Most of the presentations are in Norwegian.
JavaScript
1
star
49

express-error

Custom error handler for Express.js
JavaScript
1
star
50

facebook-apps

Static Facebook apps for https://www.facebook.com/turistforeningen/
HTML
1
star
51

teknovettreglene

Teknologi og utviklingsavdelingen i Den Norske Turistforenignen
1
star
52

sherpa-response

Simple Flask app to receive, aggregate, sort and display response times
Python
1
star
53

docker-mongo

Import backups + set up replica set in Docker Cloud and locally
Shell
1
star
54

poi-admin

Point Of Interest (POI) management system for National Trip Base (NTB). The system features easy POI management (creation and editing) with an intuitive and easy to use interface.
1
star
55

angular

Turistforeningen's AngularJS Research & Development repository. Here we experiment with making web apps using the AngularJS JavaScript framework. Don't expect anything to work and everything is just a mess of random pages and functionality.
JavaScript
1
star
56

Bifrost

In Norse mythology, Bifröst is the bridge between the land of mortals, Midgard, and the land of the gods, Asgard. The gods cross it every day to meet and decide things at Urdarbrunn (Well of Urd) under the treeYggdrasill. The bridge is a rainbow. It was built by the Æsir and is guarded by the god Heimdall.
CoffeeScript
1
star
57

ssr.js

JSON and latlon wrapper for the norwegian official place registry (SSR) from the Norwegian Mapping Authority – Kartverket – written in NodeJS
CoffeeScript
1
star
58

sherpa-prod

Production ready server setup for Sherpa using Docker containers and HAProxy load balancer
HTML
1
star