Skip to content

Commit

Permalink
merged PRs and updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Danial Farid authored and Danial Farid committed Feb 14, 2016
2 parents 7758b69 + ac9d92a commit 740b610
Show file tree
Hide file tree
Showing 19 changed files with 44 additions and 40 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Table of Content:
* image resize and center crop (native) and user controlled crop through [ngImgCrop](https://github.com/alexk111/ngImgCrop). See [crop sample](http://jsfiddle.net/xxo3sk41/1/) (html5 only)
* orientation fix for jpeg image files with exif orientation data
* resumable uploads: pause/resume upload (html5 only)
* native validation support for file type/size, image width/height/aspect ratio, video/audio duration, and `ng-required` with pluggable cusome sync or async validations.
* native validation support for file type/size, image width/height/aspect ratio, video/audio duration, and `ng-required` with pluggable custom sync or async validations.
* show thumbnail or preview of selected images/audio/videos
* supports CORS and direct upload of file's binary data using `Upload.$http()`
* plenty of sample server side code, available on nuget
Expand Down Expand Up @@ -112,7 +112,7 @@ var app = angular.module('fileUpload', ['ngFileUpload']);
app.controller('MyCtrl', ['$scope', 'Upload', function ($scope, Upload) {
// upload later on form submit or something similar
$scope.submit = function() {
if (form.file.$valid && $scope.file) {
if ($scope.form.file.$valid && $scope.file) {
$scope.upload($scope.file);
}
};
Expand Down Expand Up @@ -166,6 +166,8 @@ At least one of the `ngf-select` or `ngf-drop` are mandatory for the plugin to l
// allowInvalid default is false could allow invalid files in the model
// debouncing will postpone model update (miliseconds). See angular ng-model-options for more details.
ngf-model-invalid="invalidFile(s)" // binds the invalid selected/dropped file or files to this model.
ngf-before-model-change="beforeChange($files, ...)" // called after file select/drop and before
// model change, validation and resize is processed
ng-disabled="boolean" // disables this element
ngf-select-disabled="boolean" // default false, disables file select on this element
ngf-drop-disabled="boolean" // default false, disables file drop on this element
Expand Down Expand Up @@ -378,14 +380,16 @@ for jsob byte streaming support #359 */
Upload.jsonBlob(obj)
/* converts the value to json to send data as json string. Same as angular.toJson(obj) */
Upload.json(obj)
/* converts a dataUrl to Blob object.
/* converts a dataUrl to Blob object.*/
var blob = upload.dataUrltoBlob(dataurl, name);
/* returns true if there is an upload in progress. Can be used to prompt user before closing browser tab */
Upload.isUploadInProgress() boolean
/* downloads and converts a given url to Blob object which could be added to files model */
Upload.urlToBlob(url).then(function(blob) {...});
/* returns boolean to check if the object is file and could be used as file in Upload.upload()/http() */
Upload.isFile(obj);
/* fixes the exif orientation of the jpeg image file*/
Upload.applyExifRotation(file).then(...)
```
**ng-model**
The model value will be a single file instead of an array if all of the followings are true:
Expand Down Expand Up @@ -495,7 +499,7 @@ provided by [Coshx Labs](http://www.coshx.com/).
* Sample client and server code [demo/C#] (https://github.com/danialfarid/ng-file-upload/tree/master/demo/C%23) provided by [AtomStar](https://github.com/AtomStar)

##<a name="cors"></a>CORS
To support CORS upload your server needs to allow cross domain requests. You can achive that by having a filter or interceptor on your upload file server to add CORS headers to the response similar to this:
To support CORS upload your server needs to allow cross domain requests. You can achieve that by having a filter or interceptor on your upload file server to add CORS headers to the response similar to this:
([sample java code](https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/java/com/df/angularfileupload/CORSFilter.java))
```java
httpResp.setHeader("Access-Control-Allow-Methods", "POST, PUT, OPTIONS");
Expand Down
2 changes: 1 addition & 1 deletion demo/src/main/webapp/js/FileAPI.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions demo/src/main/webapp/js/ng-file-upload-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* progress, resize, thumbnail, preview, validation and CORS
* FileAPI Flash shim for old browsers not supporting FormData
* @author Danial <[email protected]>
* @version 12.0.0
* @version 12.0.1
*/

(function () {
Expand Down Expand Up @@ -424,7 +424,7 @@ if (!window.FileReader) {
* AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort,
* progress, resize, thumbnail, preview, validation and CORS
* @author Danial <[email protected]>
* @version 12.0.0
* @version 12.0.1
*/

if (window.XMLHttpRequest && !(window.FileAPI && FileAPI.shouldLoad)) {
Expand All @@ -445,14 +445,14 @@ if (window.XMLHttpRequest && !(window.FileAPI && FileAPI.shouldLoad)) {

var ngFileUpload = angular.module('ngFileUpload', []);

ngFileUpload.version = '12.0.0';
ngFileUpload.version = '12.0.1';

ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http, $q, $timeout) {
var upload = this;
upload.promisesCount = 0;

this.isResumeSupported = function () {
return window.Blob && (window.Blob instanceof Function) && new window.Blob().slice;
return window.Blob && (window.Blob instanceof Function) && window.Blob.prototype.slice;
};

var resumeSupported = this.isResumeSupported();
Expand Down Expand Up @@ -1199,7 +1199,7 @@ ngFileUpload.directive('ngfSelect', ['$parse', '$timeout', '$compile', 'Upload',
try {
if (!isInputTypeFile() && !document.body.contains(fileElem[0])) {
generatedElems.push({el: elem, ref: fileElem.parent()});
document.body.appendChild(fileElem[0].parent());
document.body.appendChild(fileElem.parent()[0]);
fileElem.bind('change', changeFn);
}
} catch(e){/*ignore*/}
Expand Down
4 changes: 2 additions & 2 deletions demo/src/main/webapp/js/ng-file-upload-all.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo/src/main/webapp/js/ng-file-upload-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* progress, resize, thumbnail, preview, validation and CORS
* FileAPI Flash shim for old browsers not supporting FormData
* @author Danial <[email protected]>
* @version 12.0.0
* @version 12.0.1
*/

(function () {
Expand Down
2 changes: 1 addition & 1 deletion demo/src/main/webapp/js/ng-file-upload-shim.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions demo/src/main/webapp/js/ng-file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort,
* progress, resize, thumbnail, preview, validation and CORS
* @author Danial <[email protected]>
* @version 12.0.0
* @version 12.0.1
*/

if (window.XMLHttpRequest && !(window.FileAPI && FileAPI.shouldLoad)) {
Expand All @@ -23,14 +23,14 @@ if (window.XMLHttpRequest && !(window.FileAPI && FileAPI.shouldLoad)) {

var ngFileUpload = angular.module('ngFileUpload', []);

ngFileUpload.version = '12.0.0';
ngFileUpload.version = '12.0.1';

ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http, $q, $timeout) {
var upload = this;
upload.promisesCount = 0;

this.isResumeSupported = function () {
return window.Blob && (window.Blob instanceof Function) && new window.Blob().slice;
return window.Blob && (window.Blob instanceof Function) && window.Blob.prototype.slice;
};

var resumeSupported = this.isResumeSupported();
Expand Down Expand Up @@ -777,7 +777,7 @@ ngFileUpload.directive('ngfSelect', ['$parse', '$timeout', '$compile', 'Upload',
try {
if (!isInputTypeFile() && !document.body.contains(fileElem[0])) {
generatedElems.push({el: elem, ref: fileElem.parent()});
document.body.appendChild(fileElem[0].parent());
document.body.appendChild(fileElem.parent()[0]);
fileElem.bind('change', changeFn);
}
} catch(e){/*ignore*/}
Expand Down
4 changes: 2 additions & 2 deletions demo/src/main/webapp/js/ng-file-upload.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/FileAPI.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions dist/ng-file-upload-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* progress, resize, thumbnail, preview, validation and CORS
* FileAPI Flash shim for old browsers not supporting FormData
* @author Danial <[email protected]>
* @version 12.0.0
* @version 12.0.1
*/

(function () {
Expand Down Expand Up @@ -424,7 +424,7 @@ if (!window.FileReader) {
* AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort,
* progress, resize, thumbnail, preview, validation and CORS
* @author Danial <[email protected]>
* @version 12.0.0
* @version 12.0.1
*/

if (window.XMLHttpRequest && !(window.FileAPI && FileAPI.shouldLoad)) {
Expand All @@ -445,14 +445,14 @@ if (window.XMLHttpRequest && !(window.FileAPI && FileAPI.shouldLoad)) {

var ngFileUpload = angular.module('ngFileUpload', []);

ngFileUpload.version = '12.0.0';
ngFileUpload.version = '12.0.1';

ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http, $q, $timeout) {
var upload = this;
upload.promisesCount = 0;

this.isResumeSupported = function () {
return window.Blob && (window.Blob instanceof Function) && new window.Blob().slice;
return window.Blob && (window.Blob instanceof Function) && window.Blob.prototype.slice;
};

var resumeSupported = this.isResumeSupported();
Expand Down Expand Up @@ -1199,7 +1199,7 @@ ngFileUpload.directive('ngfSelect', ['$parse', '$timeout', '$compile', 'Upload',
try {
if (!isInputTypeFile() && !document.body.contains(fileElem[0])) {
generatedElems.push({el: elem, ref: fileElem.parent()});
document.body.appendChild(fileElem[0].parent());
document.body.appendChild(fileElem.parent()[0]);
fileElem.bind('change', changeFn);
}
} catch(e){/*ignore*/}
Expand Down
4 changes: 2 additions & 2 deletions dist/ng-file-upload-all.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ng-file-upload-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* progress, resize, thumbnail, preview, validation and CORS
* FileAPI Flash shim for old browsers not supporting FormData
* @author Danial <[email protected]>
* @version 12.0.0
* @version 12.0.1
*/

(function () {
Expand Down
Loading

0 comments on commit 740b610

Please sign in to comment.