欢迎各位兄弟 发布技术文章
这里的技术是共享的
function getImageFileFromUrl(url, imageName) {
return new Promise((resolve, reject) => {
var blob = null;
var xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.setRequestHeader('Accept', 'image/jpeg');
xhr.responseType = "blob";
xhr.onload = () => {
blob = xhr.response;
let imgFile = new File([blob], imageName, { type: 'image/jpeg' });
resolve(imgFile);
};
xhr.onerror = (e) => {
reject(e)
};
xhr.send();
});
}
来自 https://www.csdn.net/tags/NtzacgysOTg0NzYtYmxvZwO0O0OO0O0O.html