Created
April 3, 2016 03:16
-
-
Save jimmycann/4e7e0bb2b54ec284f4e97d0a75755391 to your computer and use it in GitHub Desktop.
Angular Tinify S3 - Upload Controller (complete)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('angular-tinify-s3').controller('uploadCtrl',['$scope', '$window', 'Upload', | |
function($scope, $window, Upload){ | |
// Set some model defaults for the Tinify API Parameters | |
$scope.ulData={}; | |
$scope.ulData.ht=150; | |
$scope.ulData.wd=150; | |
$scope.ulData.m='fit'; | |
// Resize methods accepted (for the select box options) | |
$scope.method = [ | |
{ value: 'scale', name: 'Scale' }, | |
{ value: 'fit', name: 'Fit' }, | |
{ value: 'cover', name: 'Cover' } | |
]; | |
//Angular File Upload functions | |
var vm = this; | |
vm.submit = function(){ | |
if (vm.upload_form.file.$valid && vm.file) { | |
vm.upload(vm.file, $scope.ulData); | |
} | |
}; | |
vm.upload = function (file, ulData) { | |
Upload.upload({ | |
url: '/api/upload', | |
data:{ | |
file:file, | |
ulData:ulData | |
} | |
}).then(function() { | |
alert('Upload Complete!'); | |
}); | |
}; | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment