对于一个项目,我从多个社交网络中检索图片。我使用Pinterest,我可以列出这些引脚并将其显示为URL。但是当我想用XMLHttpRequest下载图片时,我收到一个CORS错误。检索图片时Pinterest CORS错误
是因为Pinterest的政策还是有其他方法来做我?
这里是我的代码
console.log("Url de l'image: " + this.snURL);
//bug avec Pinterest
var xhr = new XMLHttpRequest();
var _self = this;
xhr.onload = function() {
var reader = new FileReader();
reader.onloadend = function() {
console.log(reader.result);
_self.initRealisationLocalStorage();
workInProgress.Start('Traitement de l\'image');
workInProgress.Info('Traitement de l\'image');
$scope.uploadPhotoNotLocalstorage(reader.result);
}
reader.readAsDataURL(xhr.response);
};
xhr.open('GET', this.snURL);
//xhr.setRequestHeader("Access-Control-Allow-Origin","*");
xhr.responseType = 'blob';
xhr.send();
});
如果有人有一个解决方案或跑的解释,我会很高兴地听到它
没有人可以帮忙吗? – digitalTrilunaire