denoland / fresh

The next-gen web framework.
https://fresh.deno.dev
MIT License
12.17k stars 621 forks source link

multipart/form-data The connection was reset #289

Closed Kleak closed 2 years ago

Kleak commented 2 years ago

I'm trying to upload files with fresh so i put this form into a pages :

export default function Audiobook() {
  return (
    <div>
      <h1>Upload audioboks</h1>

      <form
        encType="multipart/form-data"
        action="/api/audiobooks/"
        method="post"
      >
        <div>
          <label for="author">Author:</label>
          <input type="text" name="author" />
        </div>
        <div>
          <label for="book-name">Book name:</label>
          <input type="text" name="book-name" />
        </div>
        <div>
          <label for="chapter-name">Chapter name:</label>
          <input type="text" name="chapter-name" />
        </div>
        <div>
          <label for="audio">Audio file:</label>
          <input type="file" name="audio" accept="audio/*" />
        </div>

        <input type="submit" value="upload" />
      </form>
    </div>
  );
}

/api/audiobooks/ looks like this :

export const handler = async (
  _req: Request,
  _ctx: HandlerContext,
): Promise<Response> => {
  return new Response("Audiobooks !");
};

and when i send the form i got

The connection was reset

The connection to the server was reset while the page was loading.

    The site could be temporarily unavailable or too busy. Try again in a few moments.
    If you are unable to load any pages, check your computer’s network connection.
    If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.

Does multipart/form-data supported by fresh ? if yes how can i get it working ? any examples ?

lucacasonato commented 2 years ago

Did you consume the request form data body with const form = await req.formData()?

Kleak commented 2 years ago

I don't have the opportunity since an almost empty endpoint give me the connection was reset 😟

And It look like the connection was reset before coming to my code.

lucacasonato commented 2 years ago

Would you mind creating a little demo project so I can reproduce the issue?

Kleak commented 2 years ago

Would you mind creating a little demo project so I can reproduce the issue?

I will create one probably tomorrow

Kleak commented 2 years ago

Here is a repo with the problem : https://github.com/Kleak/fresh-file-upload-bug

go to http://localhost:8000/upload and try upload a file you should see a page with Audiobook ! but you see This site can't be reached on chrome and The connection was reset on firefox

Kleak commented 2 years ago

I activate deno deploy so you can try here https://fresh-file-upload-bug.deno.dev/upload look like nothing is sent when we validate the form

Kleak commented 2 years ago

I found the problem

git001 commented 10 months ago

@Kleak

I found the problem

Please can you share the solution.

Shashank3736 commented 4 months ago

I found the problem

It will be great if you can share the problem.