Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(s3): add support for custom S3 endpoint and path-style addressing #249

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/core/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export const config = {
region: process.env.AWS_REGION,
// binary files download host address.
downloadUrl: process.env.AWS_DOWNLOAD_URL || process.env.DOWNLOAD_URL,
endpoint: process.env.S3_ENDPOINT, // optional - needed when working with S3-compatible services
forcePathStyle: toBool(process.env.S3_FORCE_PATH_STYLE), // optional - some S3 compatible services require path-style addressing
},
// Config for Aliyun OSS (https://www.aliyun.com/product/oss) when storageType value is "oss".
oss: {
Expand Down
5 changes: 4 additions & 1 deletion src/core/utils/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ function uploadFileToS3(key: string, filePath: string, logger: Logger): Promise<
sessionToken: _.get(config, 's3.sessionToken'),
region: _.get(config, 's3.region'),
});
const s3 = new AWS.S3();
const s3 = new AWS.S3({
endpoint: _.get(config, 's3.endpoint'),
s3ForcePathStyle: _.get(config, 's3.forcePathStyle'),
});
fs.readFile(filePath, (err, data) => {
if (err) {
reject(new AppError(err));
Expand Down