fix(storage): preserve explicit S3 MIME types in SeaweedFS

This commit is contained in:
2026-09-28 14:34:30 +02:00
parent a3f4a7c004
commit 790f20b499
8 changed files with 142 additions and 8 deletions

View File

@@ -250,6 +250,14 @@ export async function contract(s3, config, Bucket, { foreignBucket, probePath }
requireThat(head.ContentLength === body.length && head.Metadata.test === 'fedeo', 'HEAD-Vertrag fehlgeschlagen.');
const got = await call(s3, 'GetObject', { Bucket, Key });
requireThat(Buffer.from(await got.Body.transformToByteArray()).equals(body), 'GET-Vertrag fehlgeschlagen.');
// Generic MIME types are explicit S3 metadata even for a .pdf key. The
// upstream filer used to drop octet-stream and infer PDF on later reads.
await call(s3, 'PutObject', { Bucket, Key, Body: body, ContentType: 'application/octet-stream', Metadata: { test: 'fedeo' } });
const genericHead = await call(s3, 'HeadObject', { Bucket, Key });
const genericGet = await call(s3, 'GetObject', { Bucket, Key });
const genericBody = Buffer.from(await genericGet.Body.transformToByteArray());
requireThat(genericHead.ContentType === 'application/octet-stream' && genericGet.ContentType === 'application/octet-stream'
&& genericHead.Metadata.test === 'fedeo' && genericBody.equals(body), 'Expliziter S3-MIME-Typ wurde verändert.');
// Application exports use streams. Exercise exactly the SDK environment setting
// applied by the pilot Compose file, including empty streams.
for (const bytes of [Buffer.alloc(0), Buffer.alloc(128 * 1024, 42)]) {