gpt4 book ai didi

http - FileSaver.js 正在保存损坏的图像

转载 作者:可可西里 更新时间:2023-11-01 15:29:28 24 4
gpt4 key购买 nike

这工作正常,突然停止工作。我不确定到底发生了什么变化。

我需要通过 URL 下载多张图片。

我正在使用以下代码:
https://plnkr.co/edit/nsxgwmNYUAVBRaXgDYys?p=preview

$http({
method:"GET",
url:"imageurl"
}).then(function(response){

saveAs(new Blob([response.data]), "image.jpg");

},function(err){

});

文件大小不同,不是0字节。

最佳答案

对于其他来这里的人,请查看this solution .

需要做的是在请求中添加responseType: "blob":

$http({
method:"GET",
url:"imageurl",
responseType: "blob"
})
.then(...)

HereresponseType 有效值的文档,它说默认值是 "" 所以响应被视为文本:

"": An empty responseType string is treated the same as "text", the default type (therefore, as a DOMString).

"blob:": The response is a Blob object containing the binary data.

关于http - FileSaver.js 正在保存损坏的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47175446/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com