diff --git a/lib/remote-storage.js b/lib/remote-storage.js index 0481539..ef31545 100644 --- a/lib/remote-storage.js +++ b/lib/remote-storage.js @@ -17,6 +17,9 @@ const fs = require('fs-extra') const joi = require('joi') const klaw = require('klaw') const http = require('http') +import { NodeHttpHandler } from "@smithy/node-http-handler" +import { ProxyAgent } from "proxy-agent" +import dotenv from 'dotenv' const { codes, logAndThrow } = require('./StorageError') const fileExtensionPattern = /\*\.[0-9a-zA-Z]+$/ @@ -71,8 +74,16 @@ module.exports = class RemoteStorage { } this.bucket = creds.params.Bucket + dotenv.config(); + const proxyUrl = process.env.HTTPS_PROXY || process.env.HTTP_PROXY; // this means HTTPS proxy takes precedence + const agent = proxyUrl ? new ProxyAgent(proxyUrl) : undefined; + // https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-s3/classes/s3.html#constructor - this.s3 = new S3({ credentials, region }) + this.s3 = new S3({requestHandler: new NodeHttpHandler({ + httpAgent: agent, + httpsAgent: agent + }), + credentials, region }) } /**