The example code in the README is a little unclear at the moment:
function getS3Params(localFile, stat, callback) {
// call callback like this:
var err = new Error(...); // only if there is an error
var s3Params = { // if there is no error
ContentType: getMimeType(localFile), // just an example
};
// pass `null` for `s3Params` if you want to skip uploading this file.
callback(err, s3Params);
}
Questions:
what should the first parameter for callback be if there AREN'T any errors? (Right now we're passing hard-coded undefined as first parameter)
what sort of errors are we expecting? Should I be checking the stat object for something? I'm assuming not...
Please consider changing to something like:
function getS3Params(localFile, stat, callback) {
if (thereIsAProblem()) {
callback(new Error("Some error message..."));
}
else if(weDoNotWantToUpload(localFile))) {
callback(undefined, null);
}
else {
var s3Params = {
ContentType: getMimeType(localFile), // just an example
};
callback(undefined, s3Params);
}
}
The example code in the README is a little unclear at the moment:
Questions:
callback
be if there AREN'T any errors? (Right now we're passing hard-codedundefined
as first parameter)stat
object for something? I'm assuming not...Please consider changing to something like: