yuxuannnn_utils
Version:
31 lines (30 loc) • 854 B
TypeScript
/**
* 获取兆的字节数
* @param n
* @returns
*/
export declare const getMegabyte: (n: number) => number;
/**
* 将File对象转换成base64 可以进行不用上传到服务器也能进行图片预览
* @param file
*/
export declare const changeFileToBase64: (file: File) => Promise<string>;
/**
* 获取文件的后缀
*/
export declare const getFileSuffix: (filename: string, defaultSuffix?: string) => string;
export type TChangeBufferRet = {
buffer: ArrayBuffer;
/** 文件对应的hash */
hash: string;
/** 文件对应的后缀 例如 jpg png */
suffix: string;
/** 通过hash编译的文件名 */
filename: string;
};
/**
* 将文件进行解析生成唯一的hash
* @param file
* @returns
*/
export declare const changeBuffer: (file: File) => Promise<TChangeBufferRet>;