diff --git a/ReactS3Uploader.js b/ReactS3Uploader.js index c10e0fc..682fefe 100644 --- a/ReactS3Uploader.js +++ b/ReactS3Uploader.js @@ -33,6 +33,8 @@ var ReactS3Uploader = createReactClass({ s3path: PropTypes.string, inputRef: PropTypes.func, autoUpload: PropTypes.bool, + processEvaporateOptions: PropTypes.func, + processEvaporateConfig: PropTypes.func, evaporateOptions: PropTypes.object.isRequired, }, @@ -57,7 +59,13 @@ var ReactS3Uploader = createReactClass({ return filename.replace(/[^\w\d_\-\.]+/ig, ''); }, s3path: '', - autoUpload: true + autoUpload: true, + processEvaporateOptions: function (options, file) { + return options; + }, + processEvaporateConfig: function (config, file) { + return config; + } }; }, @@ -79,6 +87,8 @@ var ReactS3Uploader = createReactClass({ contentDisposition: this.props.contentDisposition, server: this.props.server, scrubFilename: this.props.scrubFilename, + processEvaporateOptions: this.props.processEvaporateOptions, + processEvaporateConfig: this.props.processEvaporateConfig, s3path: this.props.s3path }); }, @@ -106,7 +116,7 @@ var ReactS3Uploader = createReactClass({ if ( this.props.autoUpload ) { additional.onChange = this.uploadFile; } - + var temporaryProps = objectAssign({}, this.props, additional); var inputProps = {}; diff --git a/s3upload.js b/s3upload.js index 2aa738d..27f5e48 100644 --- a/s3upload.js +++ b/s3upload.js @@ -34,6 +34,14 @@ S3Upload.prototype.scrubFilename = function(filename) { return filename.replace(/[^\w\d_\-\.]+/ig, ''); }; +S3Upload.prototype.processEvaporateOptions = function(defaultOptions, file) { + return defaultOptions; +}; + +S3Upload.prototype.processEvaporateConfig = function(defaultConfig, file) { + return defaultConfig; +}; + function S3Upload(options) { if (options == null) { options = {}; @@ -63,9 +71,9 @@ S3Upload.prototype.uploadToS3 = function(file) { var evaporateOptions = Object.assign(this.evaporateOptions, { signerUrl: this.signingUrl }); - return Evaporate.create(evaporateOptions).then(function(evaporate){ + return Evaporate.create(this.processEvaporateOptions(evaporateOptions, file)).then(function(evaporate){ var addConfig = { - name: this.s3path + this.scrubFilename(file.name), + name: this.scrubFilename(file.name), file: file, contentType: file.type, progress: function(p, stats){ @@ -83,7 +91,7 @@ S3Upload.prototype.uploadToS3 = function(file) { }.bind(this) }; this.evaporate = evaporate; - evaporate.add(addConfig).then( + evaporate.add(this.processEvaporateConfig(addConfig, file, this.s3path)).then( function(awsKey){ return this.onFinishS3Put(awsKey, file); }.bind(this),