Skip to content

Commit

Permalink
[bug] Use "requestDefaults" options for requests to client-s3; Fix bu…
Browse files Browse the repository at this point in the history
…g 70400
  • Loading branch information
konovalovsergey committed Sep 24, 2024
1 parent c750dbc commit c8b2593
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions 3DPARTY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
9 changes: 9 additions & 0 deletions Common/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 9 additions & 0 deletions Common/sources/storage-s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,21 @@
'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');
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;
Expand All @@ -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) {
Expand Down

0 comments on commit c8b2593

Please sign in to comment.