Skip to content

toDataURL ​

将 File 对象转换为 Data URL 字符串。

使用 ​

ts
import { toDataURL } from 'rattail'

await toDataURL(new File(['Hello, world!'], 'hello.txt', { type: 'text/plain' }))
// return 'data:text/plain;base64,SGVsbG8sIHdvcmxkIQ=='

参数 ​

参数类型默认值
fileFile

返回值 ​

类型
Promise<string>