Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/remote-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]+$/
Expand Down Expand Up @@ -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 })
}

/**
Expand Down