Can't parse Deno Oak body from Post request form-data / json

163 views Asked by At

I am using Deno with Oak and Deno KV to make a S3 service clone.

Uncaught (in promise) Error: Caught error from `readSlice()` without `partial` property

This is the error I receive every time I try to parse a File or Text (base64 string) using form-data. I have tried normal short strings and it works. I tried json format with same input same result. But If I use base64 string it comes with another error:

   error: Uncaught (in promise) Interrupted: operation canceled 
   const ab = await this.#request.arrayBuffer();

Handler code:

    const body = await ctx.request.body({ type: "form-data" });
    const data = await body.value.read();
1

There are 1 answers

0
Miguelo On BEST ANSWER

I managed to solve it with for form parsing config:

const formDataReader = ctx.request.body({ type: "form-data" }).value;
const formDataBody = await formDataReader.read({ maxSize: 10000000 });
const files = formDataBody.files;