Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add process evaporate config #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions ReactS3Uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},

Expand All @@ -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;
}
};
},

Expand All @@ -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
});
},
Expand Down Expand Up @@ -106,7 +116,7 @@ var ReactS3Uploader = createReactClass({
if ( this.props.autoUpload ) {
additional.onChange = this.uploadFile;
}

var temporaryProps = objectAssign({}, this.props, additional);
var inputProps = {};

Expand Down
14 changes: 11 additions & 3 deletions s3upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down Expand Up @@ -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){
Expand All @@ -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),
Expand Down