【发布时间】:2017-05-08 22:01:42
【问题描述】:
我有一个端点,我可以像这样使用 curl 上传文本文件:
curl -X POST -H "Content-Type: multipart/form-data" -F "file=@/resources/speciesDiffusion.tree" http://localhost:4000/continuous/tree
现在我需要从浏览器发送一个类似的请求,但是
(ajax/ajax-request
{:uri (str "http://localhost:4000" "/continuous/tree")
:method :post
:params {:treefile file}
:handler #(println %1)
:format (ajax/text-request-format)
:response-format (ajax/json-response-format {:keywords? true})})
给了我一个(很好的 json 转换,所以我得到了那部分,这很好)错误响应:
[false {:status 500, :status-text , :failure :error, :response {:timestamp 1494279686227, :status 500, :error Internal Server Error, :exception org.springframework.web.multipart.MultipartException, :message Current request is not a multipart request, :path /continuous/tree}}]
另外,在浏览器中,我可以看到内容类型标头未正确设置,但我无法使其与 :format 和 :params 的任何其他组合一起使用。
【问题讨论】:
标签: ajax clojure clojurescript