Skip to content

Commit

Permalink
0.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
AckerApple committed Oct 24, 2017
1 parent b287282 commit 20792a2
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# angular-file - Change Log
All notable changes to this project will be documented here.

## [0.3.4] - 2017-10-24
- enhanced acceptFilter filter checking

## [0.3.3] - 2017-10-02
- fixed IE11 dragdrop issue

Expand Down
1 change: 1 addition & 0 deletions file-upload/FileUploader.class.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export declare class FileUploader {
onCompleteItem(item: FileItem, response: string, status: number, headers: ParsedResponseHeaders): any;
onCompleteAll(): any;
_acceptFilter(item: FileLikeObject): boolean;
acceptType(type: string): boolean;
_mimeTypeFilter(item: FileLikeObject): boolean;
_fileSizeFilter(item: FileLikeObject): boolean;
_fileTypeFilter(item: FileLikeObject): boolean;
Expand Down
31 changes: 27 additions & 4 deletions file-upload/FileUploader.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,35 @@ var FileUploader = /** @class */ (function () {
return void 0;
};
FileUploader.prototype._acceptFilter = function (item) {
return this.acceptType(item.type);
};
FileUploader.prototype.acceptType = function (type) {
if (!this.options.accept)
return true;
var acceptReg = '^((' + this.options.accept.replace(/\*/g, '.*');
acceptReg = acceptReg.replace(/,/g, ')|(') + '))$';
var regx = new RegExp(acceptReg, 'gi');
return item.type.search(regx) >= 0;
var defs = this.options.accept.split(',');
var regx = null;
var acceptRegString = null;
for (var x = defs.length - 1; x >= 0; --x) {
//Escapes dots in mimetype
acceptRegString = defs[x]; //.replace(/\./g,'\\.')
//Escapes stars in mimetype
acceptRegString = acceptRegString.replace(/\*/g, '.*');
//let acceptReg = '^((' + acceptRegString
//acceptReg = acceptReg.replace(/,/g,')|(') + '))$'
//try by mime
regx = new RegExp(acceptRegString, 'gi');
if (type.search(regx) >= 0) {
return true;
}
//try by ext
if (acceptRegString.substring(0, 1) == '.') {
regx = new RegExp(acceptRegString.substring(1, acceptRegString.length - 1) + '$');
if (type.search(regx) >= 0) {
return true;
}
}
}
return false;
};
FileUploader.prototype._mimeTypeFilter = function (item) {
return !(this.options.allowedMimeType && this.options.allowedMimeType.indexOf(item.type) === -1);
Expand Down
2 changes: 1 addition & 1 deletion file-upload/FileUploader.class.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"__symbolic":"module","version":3,"metadata":{"Headers":{"__symbolic":"interface"},"FileUploaderOptions":{"__symbolic":"interface"},"FileUploader":{"__symbolic":"class","members":{"done":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"success":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"catcher":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"},"arguments":["catch"]}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"any"}]}],"setOptions":[{"__symbolic":"method"}],"isFileValid":[{"__symbolic":"method"}],"isFilesValid":[{"__symbolic":"method"}],"getValidFiles":[{"__symbolic":"method"}],"getInvalidFiles":[{"__symbolic":"method"}],"addToQueue":[{"__symbolic":"method"}],"removeFromQueue":[{"__symbolic":"method"}],"clearQueue":[{"__symbolic":"method"}],"uploadItem":[{"__symbolic":"method"}],"cancelItem":[{"__symbolic":"method"}],"uploadAll":[{"__symbolic":"method"}],"cancelAll":[{"__symbolic":"method"}],"isFile":[{"__symbolic":"method"}],"isFileLikeObject":[{"__symbolic":"method"}],"getIndexOfItem":[{"__symbolic":"method"}],"getNotUploadedItems":[{"__symbolic":"method"}],"getReadyItems":[{"__symbolic":"method"}],"destroy":[{"__symbolic":"method"}],"onAfterAddingAll":[{"__symbolic":"method"}],"onBuildItemForm":[{"__symbolic":"method"}],"onAfterAddingFile":[{"__symbolic":"method"}],"onWhenAddingFileFailed":[{"__symbolic":"method"}],"onBeforeUploadItem":[{"__symbolic":"method"}],"onProgressItem":[{"__symbolic":"method"}],"onProgressAll":[{"__symbolic":"method"}],"onSuccessItem":[{"__symbolic":"method"}],"onErrorItem":[{"__symbolic":"method"}],"onCancelItem":[{"__symbolic":"method"}],"onCompleteItem":[{"__symbolic":"method"}],"onCompleteAll":[{"__symbolic":"method"}],"_acceptFilter":[{"__symbolic":"method"}],"_mimeTypeFilter":[{"__symbolic":"method"}],"_fileSizeFilter":[{"__symbolic":"method"}],"_fileTypeFilter":[{"__symbolic":"method"}],"_onErrorItem":[{"__symbolic":"method"}],"_onCompleteItem":[{"__symbolic":"method"}],"_headersGetter":[{"__symbolic":"method"}],"getQuedFiles":[{"__symbolic":"method"}],"getFormData":[{"__symbolic":"method"}],"_xhrTransport":[{"__symbolic":"method"}],"sendFormDataFileItem":[{"__symbolic":"method"}],"_getTotalProgress":[{"__symbolic":"method"}],"_getFilters":[{"__symbolic":"method"}],"_queueLimitFilter":[{"__symbolic":"method"}],"getFileFilterFailName":[{"__symbolic":"method"}],"_isValidFile":[{"__symbolic":"method"}],"_isSuccessCode":[{"__symbolic":"method"}],"_transformResponse":[{"__symbolic":"method"}],"_parseHeaders":[{"__symbolic":"method"}],"_onWhenAddingFileFailed":[{"__symbolic":"method"}],"_onAfterAddingFile":[{"__symbolic":"method"}],"_onAfterAddingAll":[{"__symbolic":"method"}],"_onBeforeUploadItem":[{"__symbolic":"method"}],"_onBuildItemForm":[{"__symbolic":"method"}],"_onProgressItem":[{"__symbolic":"method"}],"_onSuccessItem":[{"__symbolic":"method"}],"_onCancelItem":[{"__symbolic":"method"}],"dataUrl":[{"__symbolic":"method"}],"applyExifRotation":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"Headers":{"__symbolic":"interface"},"FileUploaderOptions":{"__symbolic":"interface"},"FileUploader":{"__symbolic":"class","members":{"done":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"success":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"catcher":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"},"arguments":["catch"]}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"any"}]}],"setOptions":[{"__symbolic":"method"}],"isFileValid":[{"__symbolic":"method"}],"isFilesValid":[{"__symbolic":"method"}],"getValidFiles":[{"__symbolic":"method"}],"getInvalidFiles":[{"__symbolic":"method"}],"addToQueue":[{"__symbolic":"method"}],"removeFromQueue":[{"__symbolic":"method"}],"clearQueue":[{"__symbolic":"method"}],"uploadItem":[{"__symbolic":"method"}],"cancelItem":[{"__symbolic":"method"}],"uploadAll":[{"__symbolic":"method"}],"cancelAll":[{"__symbolic":"method"}],"isFile":[{"__symbolic":"method"}],"isFileLikeObject":[{"__symbolic":"method"}],"getIndexOfItem":[{"__symbolic":"method"}],"getNotUploadedItems":[{"__symbolic":"method"}],"getReadyItems":[{"__symbolic":"method"}],"destroy":[{"__symbolic":"method"}],"onAfterAddingAll":[{"__symbolic":"method"}],"onBuildItemForm":[{"__symbolic":"method"}],"onAfterAddingFile":[{"__symbolic":"method"}],"onWhenAddingFileFailed":[{"__symbolic":"method"}],"onBeforeUploadItem":[{"__symbolic":"method"}],"onProgressItem":[{"__symbolic":"method"}],"onProgressAll":[{"__symbolic":"method"}],"onSuccessItem":[{"__symbolic":"method"}],"onErrorItem":[{"__symbolic":"method"}],"onCancelItem":[{"__symbolic":"method"}],"onCompleteItem":[{"__symbolic":"method"}],"onCompleteAll":[{"__symbolic":"method"}],"_acceptFilter":[{"__symbolic":"method"}],"_mimeTypeFilter":[{"__symbolic":"method"}],"_fileSizeFilter":[{"__symbolic":"method"}],"_fileTypeFilter":[{"__symbolic":"method"}],"_onErrorItem":[{"__symbolic":"method"}],"_onCompleteItem":[{"__symbolic":"method"}],"_headersGetter":[{"__symbolic":"method"}],"getQuedFiles":[{"__symbolic":"method"}],"getFormData":[{"__symbolic":"method"}],"_xhrTransport":[{"__symbolic":"method"}],"sendFormDataFileItem":[{"__symbolic":"method"}],"_getTotalProgress":[{"__symbolic":"method"}],"_getFilters":[{"__symbolic":"method"}],"_queueLimitFilter":[{"__symbolic":"method"}],"getFileFilterFailName":[{"__symbolic":"method"}],"_isValidFile":[{"__symbolic":"method"}],"_isSuccessCode":[{"__symbolic":"method"}],"_transformResponse":[{"__symbolic":"method"}],"_parseHeaders":[{"__symbolic":"method"}],"_onWhenAddingFileFailed":[{"__symbolic":"method"}],"_onAfterAddingFile":[{"__symbolic":"method"}],"_onAfterAddingAll":[{"__symbolic":"method"}],"_onBeforeUploadItem":[{"__symbolic":"method"}],"_onBuildItemForm":[{"__symbolic":"method"}],"_onProgressItem":[{"__symbolic":"method"}],"_onSuccessItem":[{"__symbolic":"method"}],"_onCancelItem":[{"__symbolic":"method"}],"dataUrl":[{"__symbolic":"method"}],"applyExifRotation":[{"__symbolic":"method"}]}}}}]
[{"__symbolic":"module","version":3,"metadata":{"Headers":{"__symbolic":"interface"},"FileUploaderOptions":{"__symbolic":"interface"},"FileUploader":{"__symbolic":"class","members":{"done":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"success":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"catcher":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"},"arguments":["catch"]}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"any"}]}],"setOptions":[{"__symbolic":"method"}],"isFileValid":[{"__symbolic":"method"}],"isFilesValid":[{"__symbolic":"method"}],"getValidFiles":[{"__symbolic":"method"}],"getInvalidFiles":[{"__symbolic":"method"}],"addToQueue":[{"__symbolic":"method"}],"removeFromQueue":[{"__symbolic":"method"}],"clearQueue":[{"__symbolic":"method"}],"uploadItem":[{"__symbolic":"method"}],"cancelItem":[{"__symbolic":"method"}],"uploadAll":[{"__symbolic":"method"}],"cancelAll":[{"__symbolic":"method"}],"isFile":[{"__symbolic":"method"}],"isFileLikeObject":[{"__symbolic":"method"}],"getIndexOfItem":[{"__symbolic":"method"}],"getNotUploadedItems":[{"__symbolic":"method"}],"getReadyItems":[{"__symbolic":"method"}],"destroy":[{"__symbolic":"method"}],"onAfterAddingAll":[{"__symbolic":"method"}],"onBuildItemForm":[{"__symbolic":"method"}],"onAfterAddingFile":[{"__symbolic":"method"}],"onWhenAddingFileFailed":[{"__symbolic":"method"}],"onBeforeUploadItem":[{"__symbolic":"method"}],"onProgressItem":[{"__symbolic":"method"}],"onProgressAll":[{"__symbolic":"method"}],"onSuccessItem":[{"__symbolic":"method"}],"onErrorItem":[{"__symbolic":"method"}],"onCancelItem":[{"__symbolic":"method"}],"onCompleteItem":[{"__symbolic":"method"}],"onCompleteAll":[{"__symbolic":"method"}],"_acceptFilter":[{"__symbolic":"method"}],"acceptType":[{"__symbolic":"method"}],"_mimeTypeFilter":[{"__symbolic":"method"}],"_fileSizeFilter":[{"__symbolic":"method"}],"_fileTypeFilter":[{"__symbolic":"method"}],"_onErrorItem":[{"__symbolic":"method"}],"_onCompleteItem":[{"__symbolic":"method"}],"_headersGetter":[{"__symbolic":"method"}],"getQuedFiles":[{"__symbolic":"method"}],"getFormData":[{"__symbolic":"method"}],"_xhrTransport":[{"__symbolic":"method"}],"sendFormDataFileItem":[{"__symbolic":"method"}],"_getTotalProgress":[{"__symbolic":"method"}],"_getFilters":[{"__symbolic":"method"}],"_queueLimitFilter":[{"__symbolic":"method"}],"getFileFilterFailName":[{"__symbolic":"method"}],"_isValidFile":[{"__symbolic":"method"}],"_isSuccessCode":[{"__symbolic":"method"}],"_transformResponse":[{"__symbolic":"method"}],"_parseHeaders":[{"__symbolic":"method"}],"_onWhenAddingFileFailed":[{"__symbolic":"method"}],"_onAfterAddingFile":[{"__symbolic":"method"}],"_onAfterAddingAll":[{"__symbolic":"method"}],"_onBeforeUploadItem":[{"__symbolic":"method"}],"_onBuildItemForm":[{"__symbolic":"method"}],"_onProgressItem":[{"__symbolic":"method"}],"_onSuccessItem":[{"__symbolic":"method"}],"_onCancelItem":[{"__symbolic":"method"}],"dataUrl":[{"__symbolic":"method"}],"applyExifRotation":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"Headers":{"__symbolic":"interface"},"FileUploaderOptions":{"__symbolic":"interface"},"FileUploader":{"__symbolic":"class","members":{"done":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"success":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"catcher":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"},"arguments":["catch"]}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"any"}]}],"setOptions":[{"__symbolic":"method"}],"isFileValid":[{"__symbolic":"method"}],"isFilesValid":[{"__symbolic":"method"}],"getValidFiles":[{"__symbolic":"method"}],"getInvalidFiles":[{"__symbolic":"method"}],"addToQueue":[{"__symbolic":"method"}],"removeFromQueue":[{"__symbolic":"method"}],"clearQueue":[{"__symbolic":"method"}],"uploadItem":[{"__symbolic":"method"}],"cancelItem":[{"__symbolic":"method"}],"uploadAll":[{"__symbolic":"method"}],"cancelAll":[{"__symbolic":"method"}],"isFile":[{"__symbolic":"method"}],"isFileLikeObject":[{"__symbolic":"method"}],"getIndexOfItem":[{"__symbolic":"method"}],"getNotUploadedItems":[{"__symbolic":"method"}],"getReadyItems":[{"__symbolic":"method"}],"destroy":[{"__symbolic":"method"}],"onAfterAddingAll":[{"__symbolic":"method"}],"onBuildItemForm":[{"__symbolic":"method"}],"onAfterAddingFile":[{"__symbolic":"method"}],"onWhenAddingFileFailed":[{"__symbolic":"method"}],"onBeforeUploadItem":[{"__symbolic":"method"}],"onProgressItem":[{"__symbolic":"method"}],"onProgressAll":[{"__symbolic":"method"}],"onSuccessItem":[{"__symbolic":"method"}],"onErrorItem":[{"__symbolic":"method"}],"onCancelItem":[{"__symbolic":"method"}],"onCompleteItem":[{"__symbolic":"method"}],"onCompleteAll":[{"__symbolic":"method"}],"_acceptFilter":[{"__symbolic":"method"}],"acceptType":[{"__symbolic":"method"}],"_mimeTypeFilter":[{"__symbolic":"method"}],"_fileSizeFilter":[{"__symbolic":"method"}],"_fileTypeFilter":[{"__symbolic":"method"}],"_onErrorItem":[{"__symbolic":"method"}],"_onCompleteItem":[{"__symbolic":"method"}],"_headersGetter":[{"__symbolic":"method"}],"getQuedFiles":[{"__symbolic":"method"}],"getFormData":[{"__symbolic":"method"}],"_xhrTransport":[{"__symbolic":"method"}],"sendFormDataFileItem":[{"__symbolic":"method"}],"_getTotalProgress":[{"__symbolic":"method"}],"_getFilters":[{"__symbolic":"method"}],"_queueLimitFilter":[{"__symbolic":"method"}],"getFileFilterFailName":[{"__symbolic":"method"}],"_isValidFile":[{"__symbolic":"method"}],"_isSuccessCode":[{"__symbolic":"method"}],"_transformResponse":[{"__symbolic":"method"}],"_parseHeaders":[{"__symbolic":"method"}],"_onWhenAddingFileFailed":[{"__symbolic":"method"}],"_onAfterAddingFile":[{"__symbolic":"method"}],"_onAfterAddingAll":[{"__symbolic":"method"}],"_onBeforeUploadItem":[{"__symbolic":"method"}],"_onBuildItemForm":[{"__symbolic":"method"}],"_onProgressItem":[{"__symbolic":"method"}],"_onSuccessItem":[{"__symbolic":"method"}],"_onCancelItem":[{"__symbolic":"method"}],"dataUrl":[{"__symbolic":"method"}],"applyExifRotation":[{"__symbolic":"method"}]}}}}]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"main": "index.js",
"version": "0.3.3",
"version": "0.3.4",
"description": "Angular file upload directives",
"module": "index.js",
"typings": "index.d.ts",
Expand Down

0 comments on commit 20792a2

Please sign in to comment.