Skip to content

Instantly share code, notes, and snippets.

@manuscrypt
manuscrypt / FileUploadRequest.elm
Last active April 27, 2019 21:11
Elm: File Upload Request
doUploadFile : Maybe AuthToken -> String -> File -> (Result Http.Error UploadedFile -> msg) -> Cmd msg
doUploadFile mbToken name file msg =
Http.request
{ method = "PUT"
, headers = [Http.header "Authorization" <| "Bearer " ++ (tokenToString mbToken)]
, url = "api/upload"
, body =
Http.multipartBody
[ Http.stringPart "name" name
, Http.filePart "file" file
module Main exposing (Flags, Model, Msg(..), init, main, subscriptions, update, view)
import Browser exposing (Document, UrlRequest)
import Browser.Navigation exposing (Key)
import Url exposing (Url)
type alias Flags =
{}