如何在黑色中接受文件上传
我有一个像这样的文件输入设置
[:p "Upload a book"]
(form-to [:post "/upload"]
(file-upload :book)
(submit-button "Upload"))
我的上传端点看起来像这样。
(defpage [:post "/upload"] {:keys [book]} (println book))
book 似乎只是上传的文件标题的字符串,而不是文件本身。我如何获取该文件?
I have a file input setup like this
[:p "Upload a book"]
(form-to [:post "/upload"]
(file-upload :book)
(submit-button "Upload"))
My upload endpoint then looks like this.
(defpage [:post "/upload"] {:keys [book]} (println book))
book just seems to be a string of the title of the file that was uploaded and not the file itself. How do I get the file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据此帖子(请参阅 Chris Granger 的第二篇文章):
您可以使用以下内容:
这是此线程的要点:
带有注释(再次来自 Chris )您需要 Leiningen 1.6.1.1+ 才不会遇到错误。
您可以在此处看到类似的内容(尽管对于 Amazon S3):
希望这会有所帮助。
According to this thread (see second post by Chris Granger):
you can use something like:
Here's a gist from this thread:
with a note (again from Chris) that you need Leiningen 1.6.1.1+ not to run into a bug.
You can see a similar thing (though for Amazon S3) here:
Hope this helps.
我认为你接受罚款;我相信您发帖错误。尝试
form-to {:enctype "multipart/form-data"}
,或从 shellcurl --form book=@/home/me/Penguins.jpg http://localhost :8080/上传
I think you're accepting fine; I believe you're posting wrong. Try
form-to {:enctype "multipart/form-data"}
, or from the shellcurl --form book=@/home/me/Penguins.jpg http://localhost:8080/Upload