Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ghostbar/angular-file-uploader

Simple Angular.js service for file-uploading
https://github.com/ghostbar/angular-file-uploader

Last synced: 8 days ago
JSON representation

Simple Angular.js service for file-uploading

Awesome Lists containing this project

README

        

angular-file-uploader [![Build Status](https://secure.travis-ci.org/ghostbar/angular-file-uploader.png)](http://travis.ci.org/ghostbar/angular-file-uploader) [![Code Climate](https://codeclimate.com/github/ghostbar/angular-file-uploader/badges/gpa.svg)](https://codeclimate.com/github/ghostbar/angular-file-uploader)
=====================

Simple Angular.js service for uploading files.

Installation
------------

Install with bower:

bower install angular-file-uploader --save

Add to your HTML files:

Now, inject to your application:

angular.module('myApp', ['file-uploader']);

Demo
----

Yeah! Got a demo already! Check it out here, explains more in-depth that the usage section here:

Usage
-----
Ready to use in your controllers!:

`file.html`:


Upload

`controller.js:`

angular.module('yourApp', ['file-uploader']);

angular.module('yourApp').controller('DemoCtrl', [
'$scope',
'FileUploader',
function ($scope, fileUploader) {
$scope.upload = function () {
var extraData = {
hey: 'Extra data'
};

fileUploader.post(
'/upload/end-point',
document.getElementById('file-to-upload').files,
extraData
)then(success, error, progress);
};
}
]);

Full API
--------

+ `FileUploader.post(url, files, config)`: makes a `POST` request.
+ `FileUploader.put(url, files, config)`: makes a `PUT` request.
+ `FileUploader.send(url, files, config)`: same as `.post()` but should not be used, is left just for compatibility with old implementations.
+ `FileUploader.request(method, url, files, config)`: This is the base function, it may change so please use either `.post()` or `.put()` unless you actually need to use a different method (really?! which method are you using??!!).

Changes on v1.0.0
-----------------

+ When loading the module just use `file-uploader` instead of `angular-file-uploader`.
+ When loading the service in your controller/directive/service use `FileUploader`.
+ Prefer to use `.post()` or `.put()` instead of the old `.send()` which should be deprecated in coming versions. `.request()` is available as well but use it only if necessary since this may change.

Author
------
© 2014-2016, Jose-Luis Rivas ``.

License
-------
The files are licensed under the MIT terms.