mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-07 19:22:14 +09:00
fix(api): honour the configured S3 addressing on uploads (#2626)
This commit is contained in:
@@ -143,6 +143,32 @@ describe('StorageService.getPresignedUploadURL', () => {
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it('gives both clients the configured addressing rather than pinning one to path style', async () => {
|
||||
await withS3Config(
|
||||
{
|
||||
endpoint: 'https://s3.example.test',
|
||||
presignedUrlBase: '',
|
||||
forcePathStyle: false,
|
||||
region: 'eu-central-1',
|
||||
accessKeyId: 'fluxer',
|
||||
secretAccessKey: 'fluxer-secret',
|
||||
buckets: {uploads: 'fluxer-uploads'},
|
||||
},
|
||||
async () => {
|
||||
const service = new StorageService();
|
||||
const probe = service as unknown as {
|
||||
client: {config: {forcePathStyle?: unknown}};
|
||||
presignClient: {config: {forcePathStyle?: unknown}};
|
||||
};
|
||||
const resolve = async (value: unknown): Promise<unknown> =>
|
||||
typeof value === 'function' ? await (value as () => Promise<unknown>)() : value;
|
||||
|
||||
expect(await resolve(probe.client.config.forcePathStyle)).toBe(false);
|
||||
expect(await resolve(probe.presignClient.config.forcePathStyle)).toBe(false);
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('StorageService.copyObjectWithMetadataStripping', () => {
|
||||
|
||||
@@ -127,7 +127,7 @@ export class StorageService implements IStorageService {
|
||||
region: this.provider.region,
|
||||
accessKeyId: this.provider.accessKeyId,
|
||||
secretAccessKey: this.provider.secretAccessKey,
|
||||
forcePathStyle: true,
|
||||
forcePathStyle: this.provider.forcePathStyle,
|
||||
});
|
||||
this.presignClient = buildPooledS3Client({
|
||||
endpoint: this.resolvePresignEndpoint(),
|
||||
@@ -136,6 +136,15 @@ export class StorageService implements IStorageService {
|
||||
secretAccessKey: this.provider.secretAccessKey,
|
||||
forcePathStyle: this.provider.forcePathStyle,
|
||||
});
|
||||
Logger.info(
|
||||
{
|
||||
endpoint: this.provider.endpoint,
|
||||
presignEndpoint: this.resolvePresignEndpoint(),
|
||||
region: this.provider.region,
|
||||
addressing: this.provider.forcePathStyle ? 'path' : 'virtual-host',
|
||||
},
|
||||
'Object storage client ready',
|
||||
);
|
||||
}
|
||||
|
||||
private resolvePresignEndpoint(): string {
|
||||
|
||||
Reference in New Issue
Block a user