對於一個項目,我從多個社交網絡中檢索圖片。我使用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