Merge branch 's3-logging' into 'develop'

Log the concatenated S3 url if constructing the S3 client fails.

See merge request firefish/firefish!10531
This commit is contained in:
Kainoa Kanter 2023-07-28 18:30:53 +00:00
commit 19762bd955

View File

@ -11,17 +11,21 @@ export function getS3(meta: Meta) {
}`
: `${meta.objectStorageUseSSL ? "https://" : "http://"}example.net`;
return new S3({
endpoint: meta.objectStorageEndpoint || undefined,
accessKeyId: meta.objectStorageAccessKey!,
secretAccessKey: meta.objectStorageSecretKey!,
region: meta.objectStorageRegion || undefined,
sslEnabled: meta.objectStorageUseSSL,
s3ForcePathStyle: !meta.objectStorageEndpoint // AWS with endPoint omitted
? false
: meta.objectStorageS3ForcePathStyle,
httpOptions: {
agent: getAgentByUrl(new URL(u), !meta.objectStorageUseProxy),
},
});
try {
return new S3({
endpoint: meta.objectStorageEndpoint || undefined,
accessKeyId: meta.objectStorageAccessKey!,
secretAccessKey: meta.objectStorageSecretKey!,
region: meta.objectStorageRegion || undefined,
sslEnabled: meta.objectStorageUseSSL,
s3ForcePathStyle: !meta.objectStorageEndpoint // AWS with endPoint omitted
? false
: meta.objectStorageS3ForcePathStyle,
httpOptions: {
agent: getAgentByUrl(new URL(u), !meta.objectStorageUseProxy),
},
});
} catch (e) {
throw new Error(`Failed to construct S3 client, assembled S3 URL: ${u}\n${e}`);
}
}