mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 21:06:04 +00:00
Merge pull request #116 from bknd-io/fix/s3-upload-in-node
fix s3 media upload in node environments by adding content length to request
This commit is contained in:
@@ -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(
|
||||||
|
|||||||
Reference in New Issue
Block a user