我将一些图片存储为blob。我使用url.createobjecturl()函数在应用程序中显示它们。
但是过一会儿,这些生成的图像将被清除,如何测试它们是否仍处于活动状态?
如果它们是活动的,请继续使用它们,如果不活动,请重新构建uri。
Im使用离子2,带有打字稿的角度2。
这是我使用JavaScript的方式:
fetch(itemObjectURL)
.then(function checkForBlobHealth(blob){
if (!blob.ok) {
console.log('❗ ' + itemObjectURL + ': Local media file not present')
//Take care of the situation, recreate or revoke ObjectURL
} else {
// Move on as usual
}
})