Coder Social home page Coder Social logo

upload's Introduction

upload

file upload and progress api

Installation

$ component install component/upload

Events

  • error an error occurred
  • abort upload was aborted
  • progress (e) upload in progress (e.percent, e.totalSize etc)
  • end upload is complete

API

Upload(file)

Initialize an Upload with the given file, where file is a File object, for example from a input.files[0] FileList.

var upload = new Upload(file);
var upload = Upload(file);

Upload#to(path, [fn])

POST the multipart upload to path and invoke fn(err, res).

upload.to('/upload');
upload.on('progress', reportProgress);
upload.on('end', done);

Running tests

Run the Express test server:

$ npm install
$ make test

License

MIT

upload's People

Contributors

forbeslindesay avatar jonathanong avatar lepture avatar swatinem avatar tj avatar tootallnate avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

upload's Issues

the library enforces POST as method of request

Currently it is hard coded 'POST' on the request method.

req.open('POST',path)

I should be able to override this with options.

PUT it a legitimate method as well if I want to override an existing resource.

new release

can we get a new release with the set-headers option? thanks

No error seems to be thrown on 404

I have added logging to 'end', 'error', 'abort', 'progress' events.
This is what I see when the post URL doesn't exist:
"progress" XMLHttpRequestProgressEvent {percent: 100}
XHR finished loading: POST "http://localhost:8000/services/image/upload"
"end" XMLHttpRequest {response: "", responseText: ""}

How come 404 doesn't give an error?
How can I catch this error?

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.