HonoH
Hono11mo ago
Mike

Image uploaded to S3 cannot be displayed when run on Lambda

I'm trying to upload images to S3 via AWS Lambda using Hono, but when I open the image url it shows The image cannot be displayed because it contains error
My Setup:
  • Frontend: SvelteKit, sending a multipart/form-data request with the image.
  • Backend: AWS Lambda with Hono
Here's my route
routes.put("/:channelId", async (c: Context) => {
  const channelId = c.req.param("channelId");

  const formData = await c.req.formData();

  const updatedChannel = await ChannelService.updateChannel(
    channelId,
    formData
  );

  return c.json(updatedChannel, 200);
});

The code for the uploading part is in the comment. It works perfectly fine on my local machine but once run on Lambda, the image is corrupted for whatever reason
Was this page helpful?