fix(AwsS3 Node): Use location constrain (#8654)

This commit is contained in:
Michael Kret 2024-02-16 15:13:26 +02:00 committed by GitHub
parent 8e9d3106a5
commit c73aeeec3d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View file

@ -284,7 +284,13 @@ export class Aws implements ICredentialType {
let path = requestOptions.qs?.path; let path = requestOptions.qs?.path;
const method = requestOptions.method; const method = requestOptions.method;
let body = requestOptions.body; let body = requestOptions.body;
let region = credentials.region; let region = credentials.region;
if (requestOptions.qs?._region) {
region = requestOptions.qs._region as string;
delete requestOptions.qs._region;
}
let query = requestOptions.qs?.query as IDataObject; let query = requestOptions.qs?.query as IDataObject;
// ! Workaround as we still use the IRequestOptions interface which uses uri instead of url // ! Workaround as we still use the IRequestOptions interface which uses uri instead of url
// ! To change when we replace the interface with IHttpRequestOptions // ! To change when we replace the interface with IHttpRequestOptions
@ -324,10 +330,10 @@ export class Aws implements ICredentialType {
} else if (service === 'sqs' && credentials.sqsEndpoint) { } else if (service === 'sqs' && credentials.sqsEndpoint) {
endpointString = credentials.sqsEndpoint as string; endpointString = credentials.sqsEndpoint as string;
} else if (service) { } else if (service) {
endpointString = `https://${service}.${credentials.region}.amazonaws.com`; endpointString = `https://${service}.${region}.amazonaws.com`;
} }
endpoint = new URL( endpoint = new URL(
endpointString!.replace('{region}', credentials.region as string) + (path as string), endpointString!.replace('{region}', region as string) + (path as string),
); );
} else { } else {
// If no endpoint is set, we try to decompose the path and use the default endpoint // If no endpoint is set, we try to decompose the path and use the default endpoint

View file

@ -29,12 +29,14 @@ export async function awsApiRequest(
service, service,
path, path,
query, query,
_region,
}, },
method, method,
body, body,
url: '', url: '',
headers, headers,
} as IHttpRequestOptions; } as IHttpRequestOptions;
if (Object.keys(option).length !== 0) { if (Object.keys(option).length !== 0) {
Object.assign(requestOptions, option); Object.assign(requestOptions, option);
} }