-
Notifications
You must be signed in to change notification settings - Fork 46
Description
The https://github.com/elm/file package provides methods for downloading strings and bytes as files, but similar methods are not included with this package. This makes it difficult for an application to generate files that can be posted with Http.multipartBody
.
Expected behavior would be to shortcut these (UX-poor) steps:
File.Download.bytes
(have user download file)File.Select.file
(have user select the same file)Http.filePart
(create a file part)Http.post
(post to server)
The net result of the above steps is essentially nothing more than attaching a name
to a Blob
, resulting in a File
. Similar steps would be used for string data.
One possible solution might be to add a function:
bytesPartToFilePart : String -> Part -> Part
to explicitly name a bytes blob.
A second solution might be to add functions to go directly from strings and bytes to file bodies.
I am proposing this change as I feel it is a relatively simple change that will open up a large variety of HTTP-based storage options for future Elm applications. I am personally exploring decentralized application file storage via IPFS and have hit a few walls from not having this feature.