Posts

Showing posts with the label upload

How to style your input file in Reagent with Bootstrap

Image
Ok this caused me a lot of headache, hope it will help anyone. In bootstrap the only way to style a input with type file, is to close it in a label. Like this: <label class="btn btn-default btn-file"> Browse <input type="file" style="display: none;"> </label>     Unfortunately, as things are now, the only way to do something like this in Reagent is to set the InnerHhtml and do something like this: (defn ^:export on-click   [event]   (js/alert "Upload Button Clicked") (defn ^:export on-change   [event]   (js/alert "File Changed) (def input-html "<input id='upload-file' name='updload-file' type='file' style='display: none;' onclick='{ns}.table.on_click(event)' onchange='{ns}.table.on_change(event);'></input>") [:label.btn.btn-primary.col-span-1      {:dangerouslySetInnerHTML       {:__html (str (label-input "Select File") input-...

How to do an upload using REST (Swagger) and Clojurescript (ajav

Hoping to help someone else that is also struggling with this. I have used Luminus with Reagent to try this. Luminus come with Swagger for REST API, it's a great tool because it gives you the possibility to try the API as soon as you have write it. This is the code to write a REST end-point that accept a file in upload (ns your-clojure-ns   (:require [ring.util.http-response :refer :all]             [compojure.api.sweet :refer :all]             [schema.core :as s]             [ring.swagger.upload :as upload]) (defapi service-routes   {:swagger {:ui "/swagger-ui"              :spec "/swagger.json"              :data {:info {:version "1.0.0"                            :title "Sample API"                 ...