Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
941 views
in Technique[技术] by (71.8m points)

clojure - How to correctly send a video to the server?

I am uploading a video to the server like so:

(reg-event-fx
 :upload-shot-video
 (fn [coeffects _]
   (prn "uploading video")
   (let [video {:uri (-> coeffects :db :shot-video-uri)}
         body (js/FormData.)]
     (prn "uri is " (-> coeffects :db :shot-video-uri))
     (.append body "video" video)
     {:http-xhrio {:method :post
                   :uri (str "http://d18a6571c2e5.ngrok.io" "/api/upload-shot-video")
                   :body body
                   :on-success [:upload-success]
                   :on-failure [:upload-error]
                   :response-format (edn/edn-response-format)}})))

where (-> coeffects :db :shot-video-uri) is the temporary uri of the image in the ios device

the handler that I have is the following:

For saving the input stream into a file video.mov

(defn upload-shot-video [req]
  (prn "uploading video")
  (prn "video is! " (-> req :params))
  (prn "video is " (-> req :body))
  (clojure.java.io/copy (-> req :body) (clojure.java.io/file "./resources/public/video.mov"))
  (r/response {:res "okay!"}))

But the size of the file is turning out to be 0 bytes, whereas I expect a size greater than 0 bytes

How to correctly send the video to the server?

question from:https://stackoverflow.com/questions/65838173/how-to-correctly-send-a-video-to-the-server

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...