Closed Wikunia closed 5 months ago
Hi @Wikunia,
In Oxygen, you can directly return the contents of a file in a route and everything works as expected. The file
function used below is a helper function that's shorthand for read(open("myfile.png"), String)
. The Content-Type
header is generated automatically based on the string's content.
If you know the type ahead of time and it remains constant then you'd be better off returning a HTTP.Response object with the correct headers
using Oxygen
get("/last_image") do
# file content is directly returned
file("myfile.png")
end
serve()
Perfect thanks!
Is there a way to return an image file for a route like
/last_image
which always returns the last image added in a folder?Best I was able to do was to return a
<img
so far using the html function but I actually just want to return the image not as html.