1

I have a api call that sends me the a stream of a file. I get the stream and put it out as an uInt8Array.

Im using this html5 example:

http://www.html5rocks.com/en/tutorials/file/xhr2/

I know what the file name and type is, how do I put this array data into a "file" and give that to the user to download?

xhr = new XMLHttpRequest()
xhr.open "GET", "#{window.API_URL}/transfer/123/2134/#{program_id}", true
xhr.responseType = "arraybuffer"
xhr.onloadstart = (e) ->
    # downloading file notify on footer
xhr.onprogress = (e) ->
    # show progress and size of file.
    console.log "#{Math.round(e.loaded/e.total)*100}% completed"
xhr.onload = (e) ->
    uInt8Array = new Uint8Array(@response)

xhr.send()

1 Answer 1

1

Try this approach (works in IE10+, FF, Chrome):

var blob = new Blob([uInt8Array], {type: contentType });

and refer to the answer

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.