gemup

0.0.2 • Public • Published

gemup

Lightweight Javascript utility for using Artsy's Gemini service to upload directly to S3. Used internally at Artsy, so not useful to general public—but open source by default!

Example

Add to your script tags

<html>
  <body>
    <script src='gemup.js'></script> 
  </body>
</html>

or require via browserify

var gemup = require('gemup');

Use a file input

<input id="my-uploader" type="file" multiple="">

Upload some files to S3 when someone changes it.

$('#my-uploader').on('change', function(e) {
  gemup(e.target.files[0],{
    app: 'force',
    key: 'SECRET_GEMINI_S3_KEY',
    fail: function(err) {
      console.log("Ouch!", err);
    },
    add: function(src) {
      console.log("We got a data-uri image client-side!", src);
    },
    progress: function(percent) {
      console.log("<3 progress bars, file is this % uploaded: ", percent);
    },
    done: function(src) {
      console.log("Done uploading, here's the S3 url: ", src);
    }
  });
});

In coffeescript:

$("#my-uploader").on "change"(e) ->
  gemup e.target.files[0],
    app: "force"
    key: "SECRET_GEMINI_S3_KEY"
    fail: (err) ->
      console.log "Ouch!"err
    add: (src) ->
      console.log "We got a data-uri image client-side!"src
    progress: (percent) ->
      console.log "<3 progress bars, file is this % uploaded: "percent
    done: (src) ->
      console.log "Done uploading, here's the S3 url: "src

Notes

Currently only works with jQuery 2.x available globally—but hopefully dropping that dependency down the line.

License

MIT

Dependencies (0)

    Dev Dependencies (4)

    Package Sidebar

    Install

    npm i gemup

    Weekly Downloads

    1

    Version

    0.0.2

    License

    none

    Last publish

    Collaborators

    • craigspaeth