Skip to content

Commit 96bf977

Browse files
authored
helper function changelog (#26741)
1 parent e79f024 commit 96bf977

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/content/changelog/workers-ai/2025-11-25-flux-2-dev-workers-ai.mdx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,20 @@ curl --request POST \
8989
Through Workers AI Binding:
9090

9191
```javascript
92+
//helper function to convert ReadableStream to Blob
93+
async function streamToBlob(stream: ReadableStream, contentType: string): Promise<Blob> {
94+
const reader = stream.getReader();
95+
const chunks = [];
96+
97+
while (true) {
98+
const { done, value } = await reader.read();
99+
if (done) break;
100+
chunks.push(value);
101+
}
102+
103+
return new Blob(chunks, { type: contentType });
104+
}
105+
92106
const image0 = await fetch("http://image-url");
93107
const image1 = await fetch("http://image-url");
94108
const form = new FormData();

0 commit comments

Comments
 (0)