Skip to content

Instantly share code, notes, and snippets.

@ry8806
Created December 24, 2015 22:10
Show Gist options
  • Select an option

  • Save ry8806/cad489345da36341fa15 to your computer and use it in GitHub Desktop.

Select an option

Save ry8806/cad489345da36341fa15 to your computer and use it in GitHub Desktop.
uploaderApp.service('S3UploadService', ['$q', function ($q) {
// Us standard region
AWS.config.region = 'us-east-1';
AWS.config.update({ accessKeyId: '**myAccessKeyId**', secretAccessKey: '**mySecretAccessKey**' });
var bucket = new AWS.S3({ params: { Bucket: 'myTempBucket', maxRetries: 10 }, httpOptions: { timeout: 360000 } });
this.Progress = 0;
this.Upload = function (file) {
var deferred = $q.defer();
var params = { Bucket: 'myTempBucket', Key: file.name, ContentType: file.type, Body: file };
var options = {
// Part Size of 10mb
partSize: 10 * 1024 * 1024,
queueSize: 1,
// Give the owner of the bucket full control
ACL: 'bucket-owner-full-control'
};
var uploader = bucket.upload(params, options, function (err, data) {
if (err) {
deferred.reject(err);
}
deferred.resolve();
});
uploader.on('httpUploadProgress', function (event) {
deferred.notify(event);
});
return deferred.promise;
};
}]);
@sushilshah
Copy link
Copy Markdown

@andrewhyeung were you able to figure out hiding the access and secret key? How can it be done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment