Last active
April 27, 2019 21:11
-
-
Save manuscrypt/2adf308bf809face1844d1f5ea298df2 to your computer and use it in GitHub Desktop.
Elm: File Upload Request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
] | |
, expect = Http.expectJson msg uploadedFileDecoder | |
, timeout = Nothing | |
, tracker = Just (File.name file) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment