[英]Image Data to Blob from XMLHttpRequest
I am making an XMLHttpRequest
:我正在制作一个
XMLHttpRequest
:
request = new XMLHttpRequest();
request.open('GET', modifiedImageUrl, true);
request.onreadystatechange = ->
if request.readyState == 4
if request.status == 200
blob = new Blob([request.response], { type: 'image/jpeg' })
request.send(null);
(Please excuse my coffeescript). (请原谅我的咖啡脚本)。 I would like to create a
Blob
from the retrieved image, but am not getting any data in my blob besides the size and type:我想从检索到的图像创建一个
Blob
,但除了大小和类型之外,我的 Blob 中没有任何数据:
Blob
size: 88804
type: "image/jpeg"
> __proto__: Object
Looking at request.response
:查看
request.response
:
What is this format?这是什么格式? How can I go about converting this to a
Blob
that has more information than just the size?我怎样才能将它转换为一个比大小更多的信息的
Blob
?
The blob has the data in it, you just can't view it like that.该 blob 中包含数据,您不能那样查看它。
Also if you didn't set your response type to arraybuffer(or blob) you image data is going to get corrupted.此外,如果您没有将响应类型设置为 arraybuffer(或 blob),您的图像数据将会损坏。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.