Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Support sendFile #205

Open
johnpyp opened this issue Oct 8, 2024 · 0 comments
Open

[Feature Request] Support sendFile #205

johnpyp opened this issue Oct 8, 2024 · 0 comments

Comments

@johnpyp
Copy link

johnpyp commented Oct 8, 2024

Similar to express, it would be great for Hono to have a sendFile function to complement serveStatic. There's a lot of custom logic that goes into serving a static file (as evidence'd by the serveStatic function), but you don't always want to just serve a static directory with predetermined paths - in a lot of cases, you may want to dynamically figure out which file to send. It's easy to just read the file into memory and send it along, but it's better to be able to support ranges, mime types, etc. automatically.

I think this api would probably look like:

import { sendFile } from '@hono/node-server/send-file'

// ...
app.get("/my-path", (c) => {

    // Can accept options similar to `serveStatic`
	return sendFile(c, filePath, { ...options })
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant