HonoRequest - Hono

Hey everyone!
I've got an annoying problem that I cannot solve with uploading multiple files over a form-data request to R2 with Hono.
const { assets, collection_name }: { assets: File[] | File; collection_name: string } = await context.req.parseBody({
  all: true,
});

The parseBody() method is a utility from Hono https://hono.dev/api/request#parsebody to unpack the assets Files to a single entry, then I try to loop over them and upload each one to R2 like so:
assets.forEach(async (asset) => {
      if (asset instanceof File) {
        const { name, size, type, lastModified } = asset;
        const filename: string = await getFilenameHash(name);
        const { uploaded, httpEtag }: R2Object = await bucket.put(
          filename,
          asset,
          {
            httpMetadata: { contentType: type },
            customMetadata: {
              name,
              collection_name,
              size: size.toString(),
              lastModified: new Date(lastModified).toString(),
            },
          },
        );
        console.log(`${uploaded} - ${httpEtag}`);
      }
    });

But no files are uploaded to R2, Miniflare reports [mf:err] TypeError: Can't read from request stream because client disconnected. while on CF infra I can see that no data is passed to the logs, only empty objects {}
If I try with a single file it works and the file is uploaded correctly, what am I doing wrong?
Screenshot_2023-11-26_13-32-56.png
Ultrafast web framework for Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, Lagon, Node.js, and others. Fast, but not only fast.
HonoRequest - Hono
Was this page helpful?