Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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;
};
}]);
@harmeetsingh0013

This comment has been minimized.

Copy link

@harmeetsingh0013 harmeetsingh0013 commented Apr 26, 2016

Hi Ryan,

This is really a great example for upload large video with in chunks. But the problems we faced is, when we start for uploading video the videos chunks size is not picked by upload process partSize. Browser by default pick less that 1 mb size for video chunks. How we resolve that issue.

@ry8806

This comment has been minimized.

Copy link
Owner Author

@ry8806 ry8806 commented May 10, 2016

hi @harmeetsign0013,
sorry for the late reply, I must have missed this in my GitHub notifications.

Could you post a small sample of your code and what's going on, have you tried increasing the "partSize" parameter in the code above to something over 10mb?

@andrewhyeung

This comment has been minimized.

Copy link

@andrewhyeung andrewhyeung commented Sep 14, 2016

Hey how would you tackle hiding the access and secret access keys?

@sushilshah

This comment has been minimized.

Copy link

@sushilshah sushilshah commented Apr 24, 2018

@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