{"id":1467,"date":"2024-11-10T09:14:15","date_gmt":"2024-11-10T01:14:15","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1467\/"},"modified":"2024-11-10T09:14:15","modified_gmt":"2024-11-10T01:14:15","slug":"b%e7%ab%99%e4%b8%bb%e9%a1%b5banner%e7%9a%84blob%e9%93%be%e6%8e%a5%ef%bc%9a%e5%a6%82%e4%bd%95%e5%88%b6%e4%bd%9c%e5%92%8c%e4%b8%8b%e8%bd%bd%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1467\/","title":{"rendered":"B\u7ad9\u4e3b\u9875Banner\u7684Blob\u94fe\u63a5\uff1a\u5982\u4f55\u5236\u4f5c\u548c\u4e0b\u8f7d\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173044271531282.jpg\" class=\"aligncenter\" title=\"B\u7ad9\u4e3b\u9875Banner\u7684Blob\u94fe\u63a5\uff1a\u5982\u4f55\u5236\u4f5c\u548c\u4e0b\u8f7d\uff1f\u63d2\u56fe\" alt=\"B\u7ad9\u4e3b\u9875Banner\u7684Blob\u94fe\u63a5\uff1a\u5982\u4f55\u5236\u4f5c\u548c\u4e0b\u8f7d\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>b\u7ad9\u4e3b\u9875banner\u7684blob\u94fe\u63a5\u63ed\u79d8<\/strong><\/p>\n<p>B\u7ad9\u4e3b\u9875\u6700\u4e0a\u65b9\u9192\u76ee\u7684Banner\u4e2d\u663e\u793a\u7684\u94fe\u63a5\u901a\u5e38\u7c7b\u4f3c\u4e8e&#8221;blob:https:\/\/xxx\u201d\uff0c\u8fd9\u79cd\u94fe\u63a5\u4e0e\u4f20\u7edf\u7684HTTP\u94fe\u63a5\u6709\u6240\u4e0d\u540c\uff0c\u88ab\u79f0\u4e3aBlob URL\u3002\u672c\u6587\u5c06\u4ecb\u7ecdBlob URL\u7684\u5236\u4f5c\u548c\u4e0b\u8f7d\u65b9\u6cd5\u3002<\/p>\n<p><strong>Blob URL\u7684\u5236\u4f5c<\/strong><\/p>\n<p>Blob URL\u662f\u4f7f\u7528\u6d4f\u89c8\u5668\u7684URL.createObjectURL()\u65b9\u6cd5\u521b\u5efa\u7684\u3002\u8be5\u65b9\u6cd5\u63a5\u6536\u4e00\u4e2aBlob\u5bf9\u8c61\u4f5c\u4e3a\u53c2\u6570\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2aBlob URL\u3002Blob\u5bf9\u8c61\u662f\u4e00\u4e2a\u8868\u793a\u4e8c\u8fdb\u5236\u6570\u636e\u7684\u5bf9\u8c61\uff0c\u53ef\u4ee5\u5305\u542b\u56fe\u50cf\u3001\u89c6\u9891\u3001\u97f3\u9891\u7b49\u591a\u79cd\u7c7b\u578b\u7684\u6570\u636e\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u8981\u5728\u6d4f\u89c8\u5668\u63a7\u5236\u53f0\u4e2d\u521b\u5efa\u6307\u5411\u56fe\u50cfBlob\u5bf9\u8c61\u7684Blob URL\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre>const imageBlob = new Blob([imageBytes], {type: 'image\/jpeg'});\nconst blobUrl = URL.createObjectURL(imageBlob);<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>Blob URL\u7684\u4e0b\u8f7d<\/strong><\/p>\n<p>\u8981\u4e0b\u8f7dBlob URL\u6307\u5411\u7684\u6570\u636e\uff0c\u53ef\u4ee5\u4f7f\u7528fetch()\u65b9\u6cd5\u5e76\u6307\u5b9aBlob URL\u4f5c\u4e3a\u53c2\u6570\u3002\u8fd4\u56de\u7684Response\u5bf9\u8c61\u4e2d\u5305\u542b\u4e00\u4e2a\u53ef\u7528\u7684Blob\u5bf9\u8c61\uff0c\u53ef\u5c06\u5176\u5b58\u50a8\u4e3a\u6587\u4ef6\u3002<\/p>\n<pre>fetch(blobUrl)\n  .then(res =&gt; res.blob())\n  .then(blob =&gt; {\n    \/\/ \u4fdd\u5b58Blob\u5bf9\u8c61\u5230\u6587\u4ef6\n  });<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cBlob URL\u7684\u751f\u5b58\u671f\u4ec5\u9650\u4e8e\u521b\u5efa\u5b83\u7684\u6d4f\u89c8\u5668\u9009\u9879\u5361\u3002\u5173\u95ed\u9009\u9879\u5361\u6216\u91cd\u65b0\u52a0\u8f7d\u9875\u9762\u540e\uff0cBlob URL\u5c06\u5931\u6548\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fB\u7ad9\u4e3b\u9875Banner\u7684Blob\u94fe\u63a5\uff1a\u5982\u4f55\u5236\u4f5c\u548c\u4e0b\u8f7d\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>b\u7ad9\u4e3b\u9875banner\u7684blob\u94fe\u63a5\u63ed\u79d8 B\u7ad9\u4e3b\u9875\u6700\u4e0a\u65b9\u9192\u76ee\u7684Banner\u4e2d\u663e\u793a\u7684\u94fe\u63a5\u901a\u5e38\u7c7b\u4f3c\u4e8e&#8221;blob:https:\/\/xxx\u201d\uff0c\u8fd9\u79cd\u94fe\u63a5\u4e0e\u4f20\u7edf\u7684HTTP\u94fe\u63a5\u6709\u6240\u4e0d\u540c\uff0c\u88ab\u79f0\u4e3aBlob URL\u3002\u672c\u6587\u5c06\u4ecb\u7ecdBlob URL\u7684\u5236\u4f5c\u548c\u4e0b\u8f7d\u65b9\u6cd5\u3002 Blob URL\u7684\u5236\u4f5c Blob URL\u662f\u4f7f\u7528\u6d4f\u89c8\u5668\u7684URL.createObjectURL()\u65b9\u6cd5\u521b\u5efa\u7684\u3002\u8be5\u65b9\u6cd5\u63a5\u6536\u4e00\u4e2aBlob\u5bf9\u8c61\u4f5c\u4e3a\u53c2\u6570\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2aBlob URL\u3002Blob\u5bf9\u8c61\u662f\u4e00\u4e2a\u8868\u793a\u4e8c\u8fdb\u5236\u6570\u636e\u7684\u5bf9\u8c61\uff0c\u53ef\u4ee5\u5305\u542b\u56fe\u50cf\u3001\u89c6\u9891\u3001\u97f3\u9891\u7b49\u591a\u79cd\u7c7b\u578b\u7684\u6570\u636e\u3002 \u4f8b\u5982\uff0c\u8981\u5728\u6d4f\u89c8\u5668\u63a7\u5236\u53f0\u4e2d\u521b\u5efa\u6307\u5411\u56fe\u50cfBlob\u5bf9\u8c61\u7684Blob URL\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\uff1a const imageBlob = new Blob([imageBytes], {type: &#8216;image\/jpeg&#8217;}); const blobUrl = URL.createObjectURL(imageBlob); \u767b\u5f55\u540e\u590d\u5236 Blob URL\u7684\u4e0b\u8f7d \u8981\u4e0b\u8f7dBlob URL\u6307\u5411\u7684\u6570\u636e\uff0c\u53ef\u4ee5\u4f7f\u7528fetch()\u65b9\u6cd5\u5e76\u6307\u5b9aBlob URL\u4f5c\u4e3a\u53c2\u6570\u3002\u8fd4\u56de\u7684Response\u5bf9\u8c61\u4e2d\u5305\u542b\u4e00\u4e2a\u53ef\u7528\u7684Blob\u5bf9\u8c61\uff0c\u53ef\u5c06\u5176\u5b58\u50a8\u4e3a\u6587\u4ef6\u3002 fetch(blobUrl) .then(res =&gt; res.blob()) .then(blob =&gt; { \/\/ \u4fdd\u5b58Blob\u5bf9\u8c61\u5230\u6587\u4ef6 }); \u767b\u5f55\u540e\u590d\u5236 \u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cBlob URL\u7684\u751f\u5b58\u671f\u4ec5\u9650\u4e8e\u521b\u5efa\u5b83\u7684\u6d4f\u89c8\u5668\u9009\u9879\u5361\u3002\u5173\u95ed\u9009\u9879\u5361\u6216\u91cd\u65b0\u52a0\u8f7d\u9875\u9762\u540e\uff0cBlob URL\u5c06\u5931\u6548\u3002 \u4ee5\u4e0a\u5c31\u662fB\u7ad9\u4e3b\u9875Banner\u7684Blob\u94fe\u63a5\uff1a\u5982\u4f55\u5236\u4f5c\u548c\u4e0b\u8f7d\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-1467","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1467","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=1467"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1467\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1467"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1467"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}