H
Hono7mo ago
PaperKrane

Is it possible to return only an image / file?

I know in Node.js you can use a function on the response called res.sendFile. I was curious if Hono has anything similar?
11 Replies
Nico
Nico7mo ago
Node.js - Hono
Ultrafast web framework for Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, Node.js, and others. Fast, but not only fast.
Nico
Nico7mo ago
Otherwise check the runtime you are using in getting started each of them should have a serve static
PaperKrane
PaperKraneOP7mo ago
Oof, I should of thought of that! I am using Bun so I'll check there. Thank you! OK, so I see how to serve static files locally, but I am interested in serving files from a CDN I have but utilizing my apps routes for example - 'example.app/files/some-file-name.jpg' will find 'some-file-name.jpg' in my CDN and return it as just the raw file but delivered from my app. I want to utilize my app's middleware to protect files for users of certain roles. Hope this makes sense. Any guidance / docs you can send would be amazing!
Nico
Nico7mo ago
I’m unsure on being a proxy server I know someone has asked before you might be able to search for it
PaperKrane
PaperKraneOP7mo ago
Thanks Nico! It means a lot!
Nico
Nico7mo ago
If you find an answer please ping me it may be helpful to add to snippets of the docs. Or if you want to add it you can
Aditya Mathur
Aditya Mathur6mo ago
I would suggest instead of being a proxy server, use authenticate-content properties of your CDN provider. By being a proxy server, you will destroy the whole purpose of a CDN. Here check these docs out for Google Cloud CDN - https://cloud.google.com/cdn/docs/authenticate-content
PaperKrane
PaperKraneOP6mo ago
I can see what you mean about losing the benefits of the CDN. I’ll check this out! By chance do you know if DigialOcean spaces supports this feature or has a similar feature? If not no biggy. I’ll check it out once I get back to my computer. Thank you so much for this idea!
Aditya Mathur
Aditya Mathur6mo ago
DO Spaces doesn't have it afaik
Aditya Mathur
Aditya Mathur6mo ago
They do have a permissions thing maybe this will help, here check it out - https://docs.digitalocean.com/products/spaces/how-to/set-file-permissions/
DigitalOcean
How to Set File Permissions and Create Quick Share Links | DigitalO...
Change the permissions of files to make them visible to anyone on the internet or only to owners of the Space). Create a quick share link to give time-bound access to a private file.
PaperKrane
PaperKraneOP6mo ago
Yeah looks like DO doesn't quite have the same control that Google appears to. The permissions allow you to generate links via the DO dashboard which isn't really great for an end user. All in all, I am trying to create a 'team' file system where a team can have access to one another's files while be restricted from other teams file library. That is where the proxy server idea came into play because I could have full control of the access control via middleware. It LOOKS like Google's authenticate content will work but for some reason I am just having a hard time visualizing the work flow. I'll explore more. Thanks so much for the insights @Aditya Mathur
Want results from more Discord servers?
Add your server