[英]How I display as image a blob object with JS
當我在控制台中登錄時,我的函數返回一個 blob 對象:
Blob(623853) {name: "profile.jpg", size: 623853, type: "image/jpeg"}
我想用 JavaScript 向用戶顯示這個圖像,我該怎么做?
您可以使用URL.createObjectURL生成 blob URL 並將其設置為圖像源。
const blobUrl = URL.createObjectURL(blob) // blob is the Blob object
image.src = blobUrl // image is the image element from the DOM
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.