diff --git a/3DPARTY.md b/3DPARTY.md index ec5deb520..6a07dce93 100644 --- a/3DPARTY.md +++ b/3DPARTY.md @@ -2,6 +2,7 @@ ## Third-party - @aws-sdk/client-s3 3.637.0 ([Apache-2.0](https://raw.githubusercontent.com/aws/aws-sdk-js-v3/main/LICENSE)) +- @aws-sdk/node-http-handler 3.374.0 ([Apache-2.0](https://raw.githubusercontent.com/aws/aws-sdk-js-v3/main/LICENSE)) - @aws-sdk/s3-request-presigner 3.370.0 ([Apache-2.0](https://raw.githubusercontent.com/aws/aws-sdk-js-v3/main/LICENSE)) - amqplib 0.8.0 ([MIT](https://raw.githubusercontent.com/amqp-node/amqplib/main/LICENSE)) - co 4.6.0 ([MIT](https://raw.githubusercontent.com/tj/co/master/LICENSE)) diff --git a/Common/npm-shrinkwrap.json b/Common/npm-shrinkwrap.json index 8bd271bec..018e87c8f 100644 --- a/Common/npm-shrinkwrap.json +++ b/Common/npm-shrinkwrap.json @@ -2771,6 +2771,15 @@ } } }, + "@aws-sdk/node-http-handler": { + "version": "3.374.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/node-http-handler/-/node-http-handler-3.374.0.tgz", + "integrity": "sha512-v1Z6m0wwkf65/tKuhwrtPRqVoOtNkDTRn2MBMtxCwEw+8V8Q+YRFqVgGN+J1n53ktE0G5OYVBux/NHiAjJHReQ==", + "requires": { + "@smithy/node-http-handler": "^1.0.2", + "tslib": "^2.5.0" + } + }, "@aws-sdk/region-config-resolver": { "version": "3.614.0", "resolved": "https://registry.npmjs.org/@aws-sdk/region-config-resolver/-/region-config-resolver-3.614.0.tgz", diff --git a/Common/package.json b/Common/package.json index b26a50ae8..85f536c3f 100644 --- a/Common/package.json +++ b/Common/package.json @@ -5,6 +5,7 @@ "private": true, "dependencies": { "@aws-sdk/client-s3": "3.637.0", + "@aws-sdk/node-http-handler": "3.374.0", "@aws-sdk/s3-request-presigner": "3.370.0", "amqplib": "0.8.0", "co": "4.6.0", diff --git a/Common/sources/storage-s3.js b/Common/sources/storage-s3.js index 603cb2b60..07ae0c67e 100644 --- a/Common/sources/storage-s3.js +++ b/Common/sources/storage-s3.js @@ -33,11 +33,13 @@ 'use strict'; const fs = require('fs'); const url = require('url'); +const { Agent } = require('https'); const path = require('path'); const { S3Client, ListObjectsCommand, HeadObjectCommand} = require("@aws-sdk/client-s3"); const { GetObjectCommand, PutObjectCommand, CopyObjectCommand} = require("@aws-sdk/client-s3"); const { DeleteObjectsCommand, DeleteObjectCommand } = require("@aws-sdk/client-s3"); const { getSignedUrl } = require("@aws-sdk/s3-request-presigner"); +const { NodeHttpHandler } = require("@aws-sdk/node-http-handler"); const mime = require('mime'); const config = require('config'); const utils = require('./utils'); @@ -45,6 +47,7 @@ const ms = require('ms'); const commonDefines = require('./../../Common/sources/commondefines'); const cfgExpSessionAbsolute = ms(config.get('services.CoAuthoring.expire.sessionabsolute')); +const cfgRequestDefaults = config.get('services.CoAuthoring.requestDefaults'); //This operation enables you to delete multiple objects from a bucket using a single HTTP request. You may specify up to 1000 keys. const MAX_DELETE_OBJECTS = 1000; @@ -71,6 +74,12 @@ function getS3Client(storageCfg) { configS3.tls = storageCfg.sslEnabled; configS3.forcePathStyle = storageCfg.s3ForcePathStyle; } + //todo dedicated options? + const agent = new Agent(cfgRequestDefaults); + configS3.requestHandler = new NodeHttpHandler({ + httpAgent: agent, + httpsAgent: agent + }); let configJson = JSON.stringify(configS3); let client = clients[configJson]; if (!client) {