Coder Social home page Coder Social logo

simple-uploader's Introduction

Simple Uploader

Latest Version Build Status Coveralls David David Gitter

A HTML5 upload component which provides full control of UI styles.

Installation

Install via npm:

npm install --save simple-uploader

Install via bower:

bower install --save simple-uploader

Usage

<script type="text/javascript" src="[script path]/jquery.js"></script>
<script type="text/javascript" src="[script path]/simple-module.js"></script>
<script type="text/javascript" src="[script path]/simple-uploader.js"></script>

<input type="file" id="upload-file" />
var uploader = simple.uploader({
  url: '/upload/url'
});

$('#upload-file').on('change', function(e) {
  uploader.upload(this.files);
});

Options

url

String, required, specify the upload API url on server.

params

Hash, specify extra params which will be sent to server with file data.

fileKey

String, specify the name that server will use to get file data.

connectionCount

Number, 3 by default, specify max number of upload connection that can exist simultaneously.

Methods

upload ([File Object]/[File Element]/[File Array])

Use this method to start uploading, accept file object or input:file element or file object arrays as the only param.

cancel ([File Object]/fileId)

Cancel uploading a specific file and remove it from the upload queue.

destroy

Cancel all uploadings and destroy the component instance.

readImageFile ([File Object], callback)

Get base64 data of an image file, which is useful to preview image before uplloading.

Events

beforeupload (e, file)

Triggered before uploading, return false to cancel uploading.

uploadprogress (e, file, loaded, total)

Triggered multiple times during uploading process.

uploadsuccess (e, file, result)

Triggered after uploading complete and response status is 200.

uploaderror (e, file, xhr, status)

Triggered after uploading complete and response status is not 200.

uploadcomplete (e, file, responseText)

Triggered after uploading complete.

uploadcancel (e, file)

Triggered when a uploading is canceled by cancel() method

Development

Clone repository from github:

git clone https://github.com/mycolorway/simple-uploader.git

Install npm dependencies:

npm install

Run default gulp task to build project, which will compile source files, run test and watch file changes for you:

gulp

Now, you are ready to go.

Publish

If you want to publish new version to npm and bower, please make sure all tests have passed before you publish new version, and you need do these preparations:

  • Check the version number in bower.json and package.json.

  • Add new release information in CHANGELOG.md. The format of markdown contents will matter, because build scripts will get version and release content from this file by regular expression. You can follow the format of the older release information.

  • Put your personal API tokens in /.token, which is required by the build scripts to request Github API for creating new release.

  • Commit changes and push.

Now you can run gulp publish task, which will request Github API to create new release.

If everything goes fine, you can see your release at https://github.com/mycolorway/simple-uploader/releases. At the End you can publish new version to npm with the command:

npm publish

Please be careful with the last step, because you cannot delete or republish a release on npm.

simple-uploader's People

Contributors

biallo avatar billyct avatar farthinker avatar frankfang avatar ruochenlyu avatar tinyfive 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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

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.