1

我有以下客户端请求:

(let [form-data (doto
                       (js/FormData.)
                     (.append "filename" file))]
     (ajax-request
      {:uri "/some/uri"
       :method :post
       :body form-data
       :format (raw-request-format)
       :response-format (raw-response-format)})
     )

在服务器上(带有解放者):

(defresource some-resource [_]
  :allowed-methods [:get :post]
  :available-media-types ["application/json"]
  :exists? (fn [ctx]
             (prn "form-data " (-> ctx :request :body slurp)) ;prints
             (prn "form-data " (-> ctx :request :body slurp cheshire/decode)) ;doesn't print
             ))

在服务器上,我确实得到了表单数据的打印,如下所示:

"form-data " "------WebKitFormBoundaryI9CA2zKhFT0Stmx7\r\nContent-Disposition: form-data; name=\"new-name\"\r\n\r\n{:uploaded-file #object[File [object File]], :name \"somename\", :another \"1234\"}\r\n------WebKitFormBoundaryI9CA2zKhFT0Stmx7--\r\n"

但是下一个 prn 不会打印我的目标是提取 :uploaded-file 的任何内容。我究竟做错了什么?

4

0 回答 0