fix s3 media upload in node environments by adding content length to request

This commit is contained in:
dswbx
2025-03-21 18:01:44 +01:00
parent ea2aa7c76c
commit 7b8c7f1ae4

View File

@@ -118,14 +118,20 @@ export class StorageS3Adapter extends AwsClient implements StorageAdapter {
const res = await this.fetch(url, { const res = await this.fetch(url, {
method: "PUT", method: "PUT",
body, body,
headers: isFile(body)
? {
// required for node environments
"Content-Length": String(body.size),
}
: {},
}); });
if (res.ok) { if (!res.ok) {
// "df20fcb574dba1446cf5ec997940492b" throw new Error(`Failed to upload object: ${res.status} ${res.statusText}`);
return String(res.headers.get("etag"));
} }
return undefined; // "df20fcb574dba1446cf5ec997940492b"
return String(res.headers.get("etag"));
} }
private async headObject( private async headObject(