From b4a0c041ec8a507659c7560915873a2f945355e0 Mon Sep 17 00:00:00 2001 From: Radjak Date: Thu, 20 Jun 2019 11:13:01 +0200 Subject: [PATCH] add policy expiration parametrable in config for AWS S3 --- lib/s3.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/s3.js b/lib/s3.js index 6b8dc1f..981b7c0 100644 --- a/lib/s3.js +++ b/lib/s3.js @@ -11,7 +11,8 @@ * keyStart: 'editor/', * acl: 'public-read', * accessKey: 'YOUR-AMAZON-S3-PUBLIC-ACCESS-KEY', -* secretKey: 'YOUR-AMAZON-S3-SECRET-ACCESS-KEY' +* secretKey: 'YOUR-AMAZON-S3-SECRET-ACCESS-KEY', +* policyExpiration: (new Date).getTime() + (60 * 60 * 1000) * } * * @return: @@ -52,8 +53,11 @@ function getHash(config) { var xAmzDate = dateString + 'T000000Z'; var policy = { - // 5 minutes into the future - expiration: new Date((new Date).getTime() + (5 * 60 * 1000)).toISOString(), + // Date or timestamp from config OR 5 minutes into the future + expiration: new Date( + config.policyExpiration + || (new Date).getTime() + (5 * 60 * 1000) + ).toISOString(), conditions: [ {bucket: bucket}, {acl: acl },