mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Allow setting region outside of endpoint (#16877)
This commit is contained in:
@@ -70,6 +70,7 @@ beforeEach(() => {
|
||||
serverSideEncryption: randWord(),
|
||||
root: randDirectoryPath(),
|
||||
endpoint: randDomainName(),
|
||||
region: randWord(),
|
||||
},
|
||||
path: {
|
||||
input: randUnique() + randFilePath(),
|
||||
@@ -203,6 +204,23 @@ describe('#constructor', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Sets region', () => {
|
||||
new DriverS3({
|
||||
key: sample.config.key,
|
||||
secret: sample.config.secret,
|
||||
bucket: sample.config.bucket,
|
||||
region: sample.config.region,
|
||||
});
|
||||
|
||||
expect(S3Client).toHaveBeenCalledWith({
|
||||
region: sample.config.region,
|
||||
credentials: {
|
||||
accessKeyId: sample.config.key,
|
||||
secretAccessKey: sample.config.secret,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test('Normalizes config path when root is given', () => {
|
||||
const mockRoot = randDirectoryPath();
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ export type DriverS3Config = {
|
||||
acl?: string;
|
||||
serverSideEncryption?: string;
|
||||
endpoint?: string;
|
||||
region?: string;
|
||||
};
|
||||
|
||||
export class DriverS3 implements Driver {
|
||||
@@ -58,6 +59,10 @@ export class DriverS3 implements Driver {
|
||||
s3ClientConfig.forcePathStyle = true;
|
||||
}
|
||||
|
||||
if (config.region) {
|
||||
s3ClientConfig.region = config.region;
|
||||
}
|
||||
|
||||
this.client = new S3Client(s3ClientConfig);
|
||||
this.bucket = config.bucket;
|
||||
this.acl = config.acl;
|
||||
|
||||
Reference in New Issue
Block a user