我有一个Web服务器,它将用户上传的文件保存到resources
文件夹中的本机文件系统中。它在开发中工作正常,但在生产中无法提供文件。
我尝试过wrap-file
和wrap-resource
,都没有用。
wrap-file
和wrap-resource
都不起作用,因为动态内容是在打包的jar之外提供的,但是两个中间件都希望项目位于jar中,as seen in the source.
相反,实际上您可以将文件对象的输入流直接传递到响应的:body
! Ring可以正确处理并正常使用,如seen in the source here。
示例代码:
(defn image-handler
[request]
(as-> request r
(:path-params r)
(:filename r)
{:status 200
:body (io/input-stream (str <your-base-path-here> r))}))