js object URL & data URL All In One
js object URL & data URL All In One
仅支持
XMLHttpRequest
✅ & 不支持Fetch API
❌
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Sending_and_Receiving_Binary_Data
object URL
createObjectURL
https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL
const obj = {
name: 'xgqfrms',
};
// blob
const blob = new Blob([JSON.stringify(obj, null, 4)], {type : 'application/json'});
// object URL
const url = URL.createObjectURL(blob);
Blob
https://developer.mozilla.org/en-US/docs/Web/API/Blob
arrayBuffer
https://developer.mozilla.org/en-US/docs/Web/API/Response/arrayBuffer
data URL
data URLs
, URLs prefixed with the data:
scheme, allow content creators to embed small files inline in documents.
They were formerly known as "data URIs
" until that name was retired by the WHATWG.
数据 URL,以 data: 为前缀的 URL 方案,允许内容创建者在文档中嵌入小文件。
在 WHATWG 停用该名称之前,它们以前被称为“数据 URI”。
data:[<mediatype>][;base64],<data>
https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
// base64 image
Base64
https://developer.mozilla.org/en-US/docs/Glossary/Base64
MIME types (IANA media types)
type/subtype
type/subtype;parameter=value
// 'Content-Type': 'text/plain;charset=UTF-8'
// 'Accept': 'application/json',
// 'Content-Type': 'application/json;charset=utf-8'
// 'Content-Type': 'application/json',
// 'Content-Type': 'application/x-www-form-urlencoded',
https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types
https://www.iana.org/assignments/media-types/media-types.xhtml
refs
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/16132296.html
未经授权禁止转载,违者必究!