我有一个api调用,它向我发送一个文件的流。我获取流并将其作为uInt8Array发布。
我正在使用这个html5示例:
http://www.html5rocks.com/en/tutorials/file/xhr2/
我知道文件名和类型,如何将这些数组数据放入“文件”中,并将其提供给用户下载?
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()发布于 2015-02-04 15:37:36
https://stackoverflow.com/questions/14857483
复制相似问题