-
Notifications
You must be signed in to change notification settings - Fork 4
Configuration
JAndritsch edited this page Dec 5, 2014
·
12 revisions
This page covers the different uploader settings and events that can be configured. To see some of these settings in action, check out the sample app provided in the project repository.
Below are all the upload settings that can be configured.
Name | Type | Description | Default | Required |
---|---|---|---|---|
bucket | String | The name of your S3 bucket | your-bucket-name | Yes |
region | String | The region where your bucket is located | your-region | Yes |
acl | String |
The Access Control List policy. The following values can be used:
|
Below are a list of upload events that you can hook into. These can be used to add custom logic around upload progress (such as generating a progress bar) or when an upload finishes/fails/retries.
For convenience, each of these methods you provide will have access to the entire uploader through "this".
Example:
var uploadSettings = {
onReady: function() {
// 'this' is the BasicS3Uploader instance
console.log("uploader is ready!", this);
}
};
Note: none of these events are required and will default to a noop function if not provided.
Name | Description | Method signature |
---|---|---|
onReady | Fires when the uploader has been initialized and ready to start uploading. | function() |
onStart | Fires when the upload has started. | function() |
onProgress | Fires every time upload progress has been made. Passes in the current bytes that have been uploaded and the total amount of bytes (file size). | function(bytesLoaded, totalBytes) |
onChunkUploaded | Fires when a single chunk has finished uploading. Passes in the chunk number that uploaded and the total number of chunks. | function(chunkNumber, totalChunks) |
onComplete | Fires when the entire upload (including all chunks) has finished. | function(fileLocationOnS3) |
onError | Fires whenever an AJAX error or uploader error occurs. Passes in an error code (for custom error messages) and a default error description. | function(errorCode, description) |
onRetry | Fires whenever an AJAX request is being retried. Passes in the number of attempts and some data about the specific request. | function(attempts, data) |
onCancel | Fires whenever the upload has been manually canceled. | function() |