react-s3-uploader
Advanced tools
Comparing version 3.2.1 to 3.3.0
{ | ||
"name": "react-s3-uploader", | ||
"version": "3.2.1", | ||
"version": "3.3.0", | ||
"description": "React component that renders a file input and automatically uploads to an S3 bucket", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,2 +13,3 @@ "use strict"; | ||
getSignedUrl: React.PropTypes.func, | ||
preprocess: React.PropTypes.func, | ||
onProgress: React.PropTypes.func, | ||
@@ -18,3 +19,6 @@ onFinish: React.PropTypes.func, | ||
signingUrlHeaders: React.PropTypes.object, | ||
signingUrlQueryParams: React.PropTypes.object, | ||
signingUrlQueryParams: React.PropTypes.oneOfType([ | ||
React.PropTypes.object, | ||
React.PropTypes.func | ||
]), | ||
uploadRequestHeaders: React.PropTypes.object, | ||
@@ -27,2 +31,6 @@ contentDisposition: React.PropTypes.string, | ||
return { | ||
preprocess: function(file, next) { | ||
console.log('Pre-process: ' + file.name); | ||
next(file); | ||
}, | ||
onProgress: function(percent, message) { | ||
@@ -46,2 +54,3 @@ console.log('Upload progress: ' + percent + '% ' + message); | ||
getSignedUrl: this.props.getSignedUrl, | ||
preprocess: this.props.preprocess, | ||
onProgress: this.props.onProgress, | ||
@@ -66,3 +75,3 @@ onFinishS3Put: this.props.onFinish, | ||
getInputProps() { | ||
getInputProps: function() { | ||
var temporaryProps = objectAssign({}, this.props, {type: 'file', onChange: this.uploadFile}); | ||
@@ -69,0 +78,0 @@ var inputProps = {}; |
@@ -22,2 +22,3 @@ react-s3-uploader | ||
accept="image/*" | ||
preprocess={this.onUploadStart} | ||
onProgress={this.onUploadProgress} | ||
@@ -53,2 +54,5 @@ onError={this.onUploadError} | ||
The `preprocess(file, next)` prop provides an opportunity to do something before the file upload begins, | ||
modify the file (scaling the image for example), or abort the upload by not calling `next(file)`. | ||
When a file is chosen, it will immediately be uploaded to S3. You can listen for progress (and | ||
@@ -179,2 +183,6 @@ create a status bar, for example) by providing an `onProgress` function to the component. | ||
##### 3.3.0 | ||
* Adding optional preprocess hook supports asynchronous operations such as resizing an image before upload [#79 #72] | ||
* Fix uglify warning [#77] | ||
##### 3.2.1 | ||
@@ -181,0 +189,0 @@ |
@@ -18,2 +18,7 @@ /** | ||
S3Upload.prototype.preprocess = function(file, next) { | ||
console.log('base.preprocess()', file); | ||
return next(file); | ||
}; | ||
S3Upload.prototype.onProgress = function(percent, status, file) { | ||
@@ -44,6 +49,8 @@ return console.log('base.onProgress()', percent, status); | ||
var file = files[i]; | ||
this.onProgress(0, 'Waiting', file); | ||
result.push(this.uploadFile(file)); | ||
this.preprocess(file, function(processedFile){ | ||
this.onProgress(0, 'Waiting', processedFile); | ||
result.push(this.uploadFile(processedFile)); | ||
return result; | ||
}.bind(this)); | ||
} | ||
return result; | ||
}; | ||
@@ -72,3 +79,3 @@ | ||
if (this.signingUrlQueryParams) { | ||
var signingUrlQueryParams = this.signingUrlQueryParams; | ||
var signingUrlQueryParams = typeof this.signingUrlQueryParams === 'function' ? this.signingUrlQueryParams() : this.signingUrlQueryParams; | ||
Object.keys(signingUrlQueryParams).forEach(function(key) { | ||
@@ -75,0 +82,0 @@ var val = signingUrlQueryParams[key]; |
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
21184
331
240