Home > @dinofe/xt-core > convertBlobToUrl

# convertBlobToUrl() function

文件对象转为 URL 链接

Signature:

export declare function convertBlobToUrl(blob: Blob | File): {
    url: string;
    revoke: () => void;
};

# Parameters

Parameter Type Description
blob Blob | File Blob (opens new window)File (opens new window) 文件对象

Returns:

{ url: string; revoke: () => void; }

结果对象 { url: string, revoke: Function }

# Remarks

使用 URL.createObjectURL (opens new window)

# Example

import { convertBlobToUrl } from '@dinofe/xt-core/web'
const file = e.target.files[0] // input元素的change事件的
const { url } = convertBlobToUrl(file)
console.log(url)