fix: add only credentials object when credentials are present

This commit is contained in:
Christian Capeans 2023-11-14 10:03:47 +01:00
parent af5a6e37b2
commit e52ced96a5
2 changed files with 3 additions and 3 deletions

View File

@ -80,7 +80,7 @@ const getConfig = ({ baseUrl, rootPath, s3Options, ...legacyS3Options }: InitOpt
const config = {
...s3Options,
...legacyS3Options,
...[credentials ? { credentials } : {}],
...(credentials ? { credentials } : {}),
};
config.params.ACL = getOr(ObjectCannedACL.public_read, ['params', 'ACL'], config);

View File

@ -89,7 +89,7 @@ function getBucketFromAwsUrl(fileUrl: string): BucketInfo {
}
// TODO Remove this in V5 since we will only support the new config structure
export const extractCredentials = (options: InitOptions): AwsCredentialIdentity => {
export const extractCredentials = (options: InitOptions): AwsCredentialIdentity | null => {
// legacy
if (options.accessKeyId && options.secretAccessKey) {
return {
@ -114,5 +114,5 @@ export const extractCredentials = (options: InitOptions): AwsCredentialIdentity
secretAccessKey: options.s3Options.credentials.secretAccessKey,
};
}
return {};
return null;
};