-
Notifications
You must be signed in to change notification settings - Fork 9
/
angular-filepicker.js
37 lines (34 loc) · 1.29 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
angular.module('filepicker', [])
.directive("filepicker", function () {
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 || '';
var store_options = {
location: 'S3',
path: path,
container: container
};
filepicker.setKey(attrs.apiKey ? attrs.apiKey : '');
filepicker.pickAndStore(picker_options, store_options, function (fpfiles) {
scope.$apply(function () {
scope.callback({file: fpfiles});
});
});
};
}
};
});