react-s3-uploader
Advanced tools
Comparing version 4.8.0 to 4.9.0
##### 4.9.0 | ||
* Better error messaging [#207] | ||
* Configurable Expires time [#208] | ||
##### 4.8.0 | ||
@@ -3,0 +8,0 @@ |
{ | ||
"name": "react-s3-uploader", | ||
"version": "4.8.0", | ||
"version": "4.9.0", | ||
"description": "React component that renders a file input and automatically uploads to an S3 bucket", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -48,3 +48,3 @@ "use strict"; | ||
}, | ||
onProgress: function(percent, message) { | ||
onProgress: function(percent, message, file) { | ||
console.log('Upload progress: ' + percent + '% ' + message); | ||
@@ -51,0 +51,0 @@ }, |
@@ -121,2 +121,3 @@ react-s3-uploader | ||
signatureVersion: 'v4', //optional (use for some amazon regions: frankfurt and others) | ||
signatureExpires: 60, //optional, number of seconds the upload signed URL should be valid for (defaults to 60) | ||
headers: {'Access-Control-Allow-Origin': '*'}, // optional | ||
@@ -123,0 +124,0 @@ ACL: 'private', // this is default |
@@ -93,3 +93,3 @@ var uuidv4 = require('uuid/v4'), | ||
Key: fileKey, | ||
Expires: 60, | ||
Expires: options.signatureExpires || 60, | ||
ContentType: mimeType, | ||
@@ -96,0 +96,0 @@ ACL: options.ACL || 'private' |
@@ -81,2 +81,11 @@ /** | ||
S3Upload.prototype._getErrorRequestContext = function (xhr) { | ||
return { | ||
response: xhr.responseText, | ||
status: xhr.status, | ||
statusText: xhr.statusText, | ||
readyState: xhr.readyState | ||
}; | ||
} | ||
S3Upload.prototype.executeOnSignedUrl = function(file, callback) { | ||
@@ -112,3 +121,7 @@ var fileName = this.scrubFilename(file.name); | ||
} catch (error) { | ||
this.onError('Invalid response from server', file); | ||
this.onError( | ||
'Invalid response from server', | ||
file, | ||
this._getErrorRequestContext(xhr) | ||
); | ||
return false; | ||
@@ -118,3 +131,7 @@ } | ||
} else if (xhr.readyState === 4 && this.successResponses.indexOf(xhr.status) < 0) { | ||
return this.onError('Could not contact request signing server. Status = ' + xhr.status, file); | ||
return this.onError( | ||
'Could not contact request signing server. Status = ' + xhr.status, | ||
file, | ||
this._getErrorRequestContext(xhr) | ||
); | ||
} | ||
@@ -128,3 +145,3 @@ }.bind(this); | ||
if (!xhr) { | ||
this.onError('CORS not supported', file); | ||
this.onError('CORS not supported', file, {}); | ||
} else { | ||
@@ -136,7 +153,15 @@ xhr.onload = function() { | ||
} else { | ||
return this.onError('Upload error: ' + xhr.status, file); | ||
return this.onError( | ||
'Upload error: ' + xhr.status, | ||
file, | ||
this._getErrorRequestContext(xhr) | ||
); | ||
} | ||
}.bind(this); | ||
xhr.onerror = function() { | ||
return this.onError('XHR error', file); | ||
return this.onError( | ||
'XHR error', | ||
file, | ||
this._getErrorRequestContext(xhr) | ||
); | ||
}.bind(this); | ||
@@ -143,0 +168,0 @@ xhr.upload.onprogress = function(e) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28662
423
240
8