This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-22
Channels
- # alda (2)
- # announcements (1)
- # babashka (32)
- # beginners (67)
- # calva (1)
- # cider (19)
- # clerk (11)
- # clj-commons (35)
- # clj-kondo (7)
- # cljsrn (2)
- # clojure (35)
- # clojure-europe (86)
- # clojure-nl (5)
- # clojure-norway (5)
- # clojure-russia (6)
- # clojurescript (16)
- # clr (21)
- # conjure (1)
- # core-async (10)
- # cryogen (1)
- # cursive (12)
- # data-science (1)
- # emacs (29)
- # events (4)
- # figwheel-main (2)
- # graalvm (9)
- # gratitude (7)
- # honeysql (4)
- # hugsql (3)
- # hyperfiddle (23)
- # jobs (1)
- # jobs-discuss (4)
- # joyride (9)
- # malli (2)
- # off-topic (81)
- # portal (7)
- # reagent (19)
- # reitit (1)
- # releases (4)
- # shadow-cljs (121)
- # xtdb (3)
Hello!
Can anyone tell me how to correctly send the file?
A photo is taken using react-native-vision-camera, data about it (PhotoFile object) is placed in db
Later, the path to the file is obtained, the name, type are filled in, translated into js and sent to the server
But I get an error: error photo is invalid
(reg-event-fx
:recognize-number
(fn [{:keys [db]} _]
(let [session-id (get-in db [:auth :data :session_id])
service-location-id (get-in db [:auth :data :service_location_id])
organization-id (get-in db [:auth :data :organization_id])
path (.-path (get-in db [:recognize :photo]))
name (last (clojure.string/split path "/"))
photo-data (clj->js
{:uri path
:name name
:type "image/jpeg"})]
{:http-xhrio {:method :post
:uri "some-url"
:params {:service_location_id service-location-id
:photo photo-data}
:headers {:accept "application/json"
:Content-Type "multipart/form-data"
:Session-Id session-id
:Organization-Id organization-id}
:format (ajax/json-request-format)
:response-format (ajax/json-response-format {:keyword? true})
:on-success [:recognize-number-success]
:on-failure [:recognize-number-error]}})))
It looks like you’re posting local details about the photo file as JSON instead of the photo itself. I.e., the server is getting an object that looks like {"uri": "
. I think you’re going to need to get the file data and send it as a multipart attachment.