-
Notifications
You must be signed in to change notification settings - Fork 46
Closed
Description
We have a situation where we fetch binary data with http, then prompt the user, then use Download.bytes to allow the user to save the file.
In IE11, using expectBytesResponse yields InvalidStateException b/c Blobs cannot be initialized from array buffers. This is because expectBytesResponse sets xhr.responseType = 'arraybuffer'.
Run this in IE11 to see the Blob constructor issue in isolation.
new Blob( new ArrayBuffer([123]), { type: 'application/*' } );
We were able to solve the problem by creating a new expect factory function like this.
expectBlobResponse : (Result x a -> msg) -> (Http.Response Bytes -> Result x a) -> Http.Expect msg
expectBlobResponse toMsg toResult =
Elm.Kernel.Http.expect "blob" identity (toResult >> toMsg)
We really don't want people to use Elm.Kernel inside of their application code so I'm gonna submit a PR to add this to the library.
Please let me know what you think. :)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels