We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8f05757 commit ecd6b17Copy full SHA for ecd6b17
1 file changed
packages/shared/storage/r2.ts
@@ -69,11 +69,18 @@ export function createR2Storage(config: R2Config): Storage {
69
},
70
71
async write(key: string, content: Uint8Array | string): Promise<void> {
72
+ // Always convert to Uint8Array and set ContentLength to avoid
73
+ // "Stream of unknown length" errors with S3-compatible storage
74
+ const body = typeof content === "string"
75
+ ? new TextEncoder().encode(content)
76
+ : content;
77
+
78
await client.send(
79
new PutObjectCommand({
80
Bucket: bucket,
81
Key: key,
- Body: content,
82
+ Body: body,
83
+ ContentLength: body.length,
84
}),
85
);
86
0 commit comments