ring-clojure / ring

Clojure HTTP server abstraction
MIT License
3.75k stars 519 forks source link

How do I use resource-response with absolute path,here I found nothing wrong but can't handle this #399

Closed nesteiner closed 4 years ago

nesteiner commented 4 years ago

Here I have a file named "1.jpg" in "/home/steiner/picture/",then I use

(resouce-response "/home/steiner/picture/1.jpg")

however it returns nil
what about :root option??

(resource-response "/home/steiner/picture/1.jpg" {:root "/"})

still nil also this is useless too

(resource-response "1.jpg" {:root "/home/steiner/picture/"})

what's the wrong with my operation??

weavejester commented 4 years ago

While I don't mind answering some questions, the Ring issue tracker should mainly be reserved for issues with Ring, rather than basic usage questions. Instead, I'd recommend asking questions on the Clojurians Slack channel, or the Ring Google Group, or the Clojure Google Group, or /r/clojure.

In your case, the problem you have is that you want to return a file, and not a resource. The file-response function is what you want. A resource exists on the Java classpath, and is typically something you'd place in the resources directory of your project.