- From: guest271314 <notifications@github.com>
- Date: Sun, 22 Mar 2020 11:47:42 -0700
- To: w3c/FileAPI <FileAPI@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Sunday, 22 March 2020 18:47:54 UTC
AFAICT `const blob = await new Response(stream).blob();` throws a `TypeError` `Promise {<rejected>: TypeError: Failed to fetch}` The concept appears to be similar what is possible with Native File System, e.g., ``` const fileFromStream = async(stream, fileName) => { const dir = await FileSystemDirectoryHandle.getSystemDirectory({ type: 'sandbox' }); await stream .pipeTo(await (await dir.getFile(fileName, { create: true })) .createWritable(), { preventCancel: true }); const file = (await dir.getFile(fileName)).getFile(); // cleanup potential lingering temporary file (until page refreshed) in sandbox await dir.removeEntry(fileName); // sanity check for await(let entry of dir.getEntries()) { console.log(await entry); if (entry.isDirectory) await entry.removeRecursively(); else await dir.removeEntry(fileName); } return file; } fileFromStream(new ReadableStream({start(c) {c.enqueue('1'); c.close()}}), 'file') .then(console.log, console.error); ``` -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/w3c/FileAPI/issues/140#issuecomment-602253992
Received on Sunday, 22 March 2020 18:47:54 UTC