Psi
Psi
HHono
Created by Icy on 2/24/2025 in #help
How to handle file uploads
I'm a DevOps guy and you want to use ObjectStorage when someone manages it for you cause he thinks its better choice for the infrastructure 😉 I mostly implement both variants, Disk and S3 but store my metadata in my own DB
44 replies
HHono
Created by Icy on 2/24/2025 in #help
How to handle file uploads
Or if you need to scale out
44 replies
HHono
Created by Icy on 2/24/2025 in #help
How to handle file uploads
If you want a object store depends very on your infrastructure and not so much on your business logic.
44 replies
HHono
Created by Icy on 2/24/2025 in #help
How to handle file uploads
Pls share if you coming up with a nice multipart solution 😉
44 replies
HHono
Created by Icy on 2/24/2025 in #help
How to handle file uploads
even with multipart uploads you need something to remove partly uploaded files
44 replies
HHono
Created by Icy on 2/24/2025 in #help
How to handle file uploads
I've a garbage collection which removes files which do not have references
44 replies
HHono
Created by Icy on 2/24/2025 in #help
How to handle file uploads
I'm partly happy with this approach. Good user experience but not so easy to implement
44 replies
HHono
Created by Icy on 2/24/2025 in #help
How to handle file uploads
Currently I do async file uploads, means, I have several types of files in my form and when the user clicks "save" I will first upload each file as body-stream. My backend responds with a uuid representing the file. I assoicate than the uuid to the current Item and store the item
44 replies
HHono
Created by Icy on 2/24/2025 in #help
How to handle file uploads
createWriteStream is from "node:fs" and pipeline from "stream/promises"
44 replies
HHono
Created by Icy on 2/24/2025 in #help
How to handle file uploads
I've also this package in my bookmarks but never used: https://github.com/mjackson/remix-the-web/tree/main/packages/form-data-parser Pro: build on standards and does not depend node-streams afaik
44 replies
HHono
Created by Icy on 2/24/2025 in #help
How to handle file uploads
There is a hono-upload lib which wraps busboy: https://github.com/ps73/hono-upload Probably this could be used or give you a direction.
44 replies
HHono
Created by Icy on 2/24/2025 in #help
How to handle file uploads
// controller
const bodyStream = c.req.raw.body;
let readableStream = Readable.fromWeb(bodyStream);
const fileMetadata = await fileStorage.upload(metadata, readableStream);

// fileStorage.uploade
const writeStream = createWriteStream(targetFilePath);
await pipeline(readableStream, writeStream);
// controller
const bodyStream = c.req.raw.body;
let readableStream = Readable.fromWeb(bodyStream);
const fileMetadata = await fileStorage.upload(metadata, readableStream);

// fileStorage.uploade
const writeStream = createWriteStream(targetFilePath);
await pipeline(readableStream, writeStream);
Thats stripped down what I do currently.
44 replies
HHono
Created by Icy on 2/24/2025 in #help
How to handle file uploads
Do you really need to use multipart formdata? Streaming a body is much simpler
44 replies