Hono Storage is a storage helper for Hono, this module is like multer in expressjs.
Warning
This is a work in progress. The code is not yet ready for production use.
npm install @hono-storage/core
you can use helper to install storage for Hono.
npm install @hono-storage/node-disk # for nodejs disk storage
npm install @hono-storage/memory # for in-memory storage
npm install @hono-storage/s3 # for s3 storage (or r2 storage)
import { Hono } from "hono";
const app = new Hono();
const storage = // your storage, see below
app.post("/upload/single", storage.single("image"), (c) => c.text("OK"));
app.post("/upload/multiple", storage.multiple("pictures"), (c) => c.text("OK"));
app.post(
"/upload/field",
storage.fields({
image: { type: "single" },
pictures: { type: "multiple", maxCount: 2 },
}),
(c) => c.text("OK"),
);
// and you can get parsed formData easily
app.post("/upload/vars", storage.single("image"), (c) => {
const { image } = c.var.files;
// do something with file
return c.text("OK");
});
// serve app
Normal Storage
import { HonoStorage } from "@hono-storage/core";
const storage = new HonoStorage(