vtlab-generic-functions 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vtlab-generic-functions",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "scripts": {
5
5
  "test": "jest"
6
6
  },
@@ -9,6 +9,7 @@
9
9
  "@aws-sdk/client-s3": "^3.478.0",
10
10
  "@aws-sdk/client-ses": "^3.478.0",
11
11
  "@aws-sdk/client-sqs": "^3.478.0",
12
+ "@aws-sdk/s3-request-presigner": "^3.484.0",
12
13
  "axios": "^1.6.2",
13
14
  "countries-code": "^1.1.0",
14
15
  "country-data": "0.0.31",
package/s3bucket/index.js CHANGED
@@ -1,4 +1,5 @@
1
- const { S3Client, PutObjectCommand, GetObjectCommand, getSignedUrl } = require("@aws-sdk/client-s3");
1
+ const { S3Client, PutObjectCommand, GetObjectCommand } = require("@aws-sdk/client-s3");
2
+ const { getSignedUrl } = require("@aws-sdk/s3-request-presigner");
2
3
  const config = require('../config');
3
4
  const multer = require('multer');
4
5
  const multerS3 = require('multer-s3');
@@ -151,8 +152,11 @@ const uploadFilesToS3 = async (path, files, extension = 'pdf', options = {
151
152
  * @returns {Promise<string>} - A promise that resolves to the presigned URL.
152
153
  * @throws {Error} - Throws an error if the URL generation fails.
153
154
  */
154
- const generatePresignedUrl = async (bucket, key, expirationInSeconds = 86400 * 30) => {
155
+ const generatePresignedUrl = async (bucket, key, expirationInSeconds = 604000) => {
155
156
  try {
157
+ if(expirationInSeconds > 604000){ //7 days is the max expiration time for a presigned url v4
158
+ expirationInSeconds = 604000;
159
+ }
156
160
  const s3Client = new S3Client();
157
161
 
158
162
  const command = new GetObjectCommand({