xeqi / peridot

a basic api for interacting with ring apps
145 stars 20 forks source link

Can I send a string as multipart-params? #53

Open zendevil opened 2 years ago

zendevil commented 2 years ago

My app is set up in a way that there are two multipart keys, one of which is a string, and the other is a file. Is there a way I can use peridot in my tests, whereby I can send one of the multipart param as a string and the other as a file? I sending the request in reframe like so:

(let [form-data (doto 
                                  (js/FormData.)
                                  (.append "file" (:org/dropped-image db))
                                  (.append "org-name" new-org-name))]
                 {:http-xhrio {:method          :put
                               :uri             (str "/api/organizations/" 
                                                     (-> db :auth/current-user 
                                                      (get "organization")
                                                      (get "id"))) 
                               :body form-data
                               :response-format (ajax/json-response-format {:keywords true?})
                               :format          (ajax/json-request-format)
                               :on-success      [:org/success-save-changes]
                               :on-failure      [:org/failure-save-changes]}})