xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

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

https://www.iana.org/

refs



©xgqfrms 2012-2020

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2022-04-11 21:52  xgqfrms  阅读(107)  评论(2编辑  收藏  举报