GithubHelp home page GithubHelp logo

isabella232 / bucky.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from olahol/bucky.js

0.0 0.0 0.0 104 KB

Easily enable S3 CORS uploading on elements. Supports drag&drop and multiple file input.

CoffeeScript 100.00%

bucky.js's Introduction

bucky.js (0.1.0)

Easily enable S3 CORS uploading on elements. Supports drag&drop and multiple file input.

Example

You will need:

  • S3 bucket with suitable CORS configuration.
  • A way to generate valid POST policies for said bucket. Policies should include success_action_status = 200 and probably Content-Type too.
var fileInput = document.getElementById("fileInput");
var dropArea = document.getElementById("dropArea");
var upload = bucky("mybucket", fileInput, dropArea);

upload.start = function () {
  // Fired before requests
  console.log("Starting upload ...");
};

upload.policy = function (file, cb) {
  // Fill in policy for file, usually done by an ajax call.
  var policy = {
    key: file.name
    , AWSAccessKey: "..."
  };
  cb(policy);
};

upload.progress = function (loaded, total) {
  var progress = Math.round(100 * loaded / total, 0);
  console.log(progress + "%");
};

upload.fail = function (file, key) {
  console.log("Failed to upload " + file.name);
};

upload.done = function (file, key) {
  console.log(file.name + " => " + key);
};

upload.stop = function () {
  console.log("Upload done.");
};

API

instance = bucky(bucketName, elements...)

Creates a new bucky and enables uploading to bucketName on elements. If an element is not input file multiple enable drag&drop.


instance.start = function ()

Before uploading process has begun.


instance.policy = function (file, callback(policy))

Before each file is uploaded. policy must be a javascript object.


instance.progress = function (loaded, total)

Progress handler, loaded is the number of bytes uploaded, total is the total number of bytes to upload.


instance.fail = function (file, key)

If a file upload fails.


instance.done = function (file, key)

When a file upload finishes.


instance.stop = function (file, key)

After uploading process finishes.

bucky.js's People

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.