oak icon indicating copy to clipboard operation
oak copied to clipboard

Multipart form-data parsing/stream handling problem

Open alkan opened this issue 3 years ago • 3 comments

OAK v9.0.0

When a form-data is posted or put, it works well with primitive form fields,but if the form-ata contains a file:

  • Time to respond takes much more time than expected
  • formdata.files entpies are created propersy, except content field is undefined
  • And there are no error messages

alkan avatar Aug 23 '21 12:08 alkan

A more complete reproduction is required. Like what version of Deno you are using, what your command line looks like and a minimal reproduction of code.

  • Time to respond takes much more time than expected

That is a very vague statement.

kitsonk avatar Aug 23 '21 12:08 kitsonk

Thank you for your prompt respond.

Deno: 1.13.1 Oak: 9.0.0

The server code has been simply taken from Oak documentation and tests:

const body = ctx.request.body({type: 'form-data'})
const formdata = await body.value.read()

That's all. Here I got a FormData structure with fields and files elements. formdata.files[0].content is undefined, however, rest of the structure is perfectsy ok.

And the client runs on Deno 1.13.1 as well. I am preparing the request as follows:

    const formdata = new FormData()
    formdata.set('filename', basename)
    //...
    const file = Deno.readFileSync(filepath)
    const blob = new Blob(file, {type: 'application/zip'})
    formdata.set('datafile', blob, basename)
    const response = await fetch(url, {
        method: 'PUT',
        body: formdata
    })

alkan avatar Aug 24 '21 10:08 alkan

any progress here? thanks.

bedirhan avatar Sep 08 '21 11:09 bedirhan