3 changed files with 1 additions and 26 deletions
@ -1,24 +0,0 @@
@@ -1,24 +0,0 @@
|
||||
const data: any = {}; |
||||
export const getAssets = (url) => { |
||||
return new Promise((resolve, reject) => { |
||||
if (data[url]) { |
||||
resolve(data[url]); |
||||
} else { |
||||
const xhr = new XMLHttpRequest(); |
||||
xhr.open('GET', url, true); |
||||
xhr.responseType = 'blob'; |
||||
xhr.onload = function () { |
||||
const blob = xhr.response; |
||||
const file = new File([blob!], url, { type: blob!.type }); |
||||
console.log(file); |
||||
data[url] = URL.createObjectURL(file); |
||||
console.log(data[url]); |
||||
resolve(data[url]); |
||||
// } else {
|
||||
// resolve(null);
|
||||
// }
|
||||
}; |
||||
xhr.send(); |
||||
} |
||||
}); |
||||
}; |
Loading…
Reference in new issue