forked from PlakeSide/angular-filepicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
angular-filepicker.js
38 lines (36 loc) · 1.03 KB
/
angular-filepicker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//Inject API KEY
angular.module('app')
.directive("filepicker", function(FILEPICKER_APIKEY){
return {
scope: {
callback: '&',
'pickerclass': '@'
},
transclude: true,
restrict: "A",
template: "<a href='javascript:;' class='{{pickerclass}}' ng-click='pickFiles()' ng-transclude></a>",
link: function(scope, element, attrs) {
scope.pickFiles = function () {
var picker_options = {
container: 'modal',
mimetypes: attrs.mimetypes ? eval(attrs.mimetypes) : ['*'],
multiple: attrs.multiple ? eval(attrs.multiple) : false
};
var path = attrs.path ? attrs.path : '/uploads/',
container = attrs.container ? attrs.container : 'documents.e-freightliner.com';
var store_options = {
location: 'S3',
path: path,
container: container
};
//Set filepicker.io apikey
filepicker.setKey(FILEPICKER_APIKEY);
filepicker.pickAndStore(picker_options, store_options, function (fpfiles) {
scope.$apply(function(){
scope.callback({file:fpfiles});
});
});
};
}
};
});