diff --git a/lib/authorizer/aws4.js b/lib/authorizer/aws4.js index a7f4f94bb..1fe938106 100644 --- a/lib/authorizer/aws4.js +++ b/lib/authorizer/aws4.js @@ -71,9 +71,16 @@ var _ = require('lodash'), return callback(hash.digest(digestEncoding)); } - // @todo: formdata body type requires adding new data to form instead of setting headers for AWS auth. + // @todo: formdata body type for S3 requires adding new data to form instead of setting headers for AWS auth. // Figure out how to do that. See below link: // AWS auth with formdata: https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-post-example.html + // For now, sign requests as other POST requests for use with API gateway and Lambda functions. + if (body.mode === RequestBody.MODES.formdata) { + formdataBody = bodyBuilder.formdata(body.formdata).body; + hash.update(formdataBody); + + return callback(hash.digest(digestEncoding)); + } // ensure that callback is called if body.mode doesn't match with any of the above modes return callback();