using fetch() to POST tar file implementation:
const ab = new ArrayBuffer(1024 * 1024);
const buf = new Buffer(ab);
const mw = new MultipartWriter(buf);
const f = await open(path.resolve('test.tar'), {
read: true,
});
await mw.writeFile('myTestField', 'test.tar', f);
const contentType = mw.formDataContentType();
await mw.close();
f.close();
const response1 = await fetch('http://localhost:8080/test', {
headers: [
['Content-Type', contentType]
],
method: 'POST',
body: ab,
});
if (response != undefined) {
await response.arrayBuffer();
assertEquals(200, response.status);
}
fails with ReadableStream:
Error: not implemented
at Object.notImplemented ($deno$/util.ts:64:9)
at fetch ($deno$/web/fetch.ts:572:11)
Is there an alternative way to have it done in Deno?
@marcosc90 I think you had a similar PR but cannot find it
Looks like this https://github.com/denoland/deno/pull/5831
Thanks @marcosc90. This issue is still valid as ReadableStream variant is not implemented.
Supporting ReadableStreams is fairly easy on TS side. I don't know rust yet to modify op_fetch so we get a resource we can write to.
related to https://github.com/denoland/deno/pull/6093
@marcosc90 thank you for looking into this issue!