![bd35ee9eae57dabdf510281dfee76c2d.png](https://i-blog.csdnimg.cn/blog_migrate/823f45498806da573890210736009e1b.jpeg)
![ec5c13a4780d55e2705129d2bbcccf6c.png](https://i-blog.csdnimg.cn/blog_migrate/bae58eee0bd736679fb83561f0c569f5.jpeg)
本文首发于:https://github.com/bigo-frontend/blog/ 欢迎关注、转载。
前言
先介绍一下js文件类型的知识点,后面要多次转换文件类型。
一.什么是Blob、File、DataURL
Blob 类型
Blob 类型是 File 文件类型的父类,它表示一个不可变、原始数据的类文件对象。 如何得到 blob 对象?
new Blob(array, options)
let hiBlob = new Blob([`<h1>Hi gauseen!<h1>`], {
type: 'text/html' })
如上代码,就创建了一个 blob 对象,并声明了 text/html 类型 ,就像是创建一个 .html 文件。只不过它存在于浏览器的内存里。
File 类型
File 包含文件的相关信息