Skip to content

urlToBlob

将 URL 转换为 Blob。

用法

js
import { urlToBlob } from 'js-cool'

签名

typescript
function urlToBlob(url: string): Promise<Blob>

参数

参数类型描述
urlstring要获取的 URL

返回值

Promise<Blob> - Blob 对象。

示例

js
const blob = await urlToBlob('https://example.com/image.png')

// 用于文件下载
const blob = await urlToBlob(fileUrl)
const url = URL.createObjectURL(blob)

相关

基于 MIT 许可发布