file-utils-plus
v1.0.1
Published
文件上传以及常用的公共方法
Downloads
3
Maintainers
Readme
file-utils-plus
AliOss, QiniuOss and other upload capabilities,common functions of files。
Installation
npm install file-utils-plus
//or
yarn add file-utils-plus
Ali-oss use:
import { uploadFileToAliOss, AliOptions } from 'file-utils-plus'
export const uploadFileToOSS = async (file: File,path: string,baseUrl: string, options: AliOptions, argument?: Object) => {
return uploadFileToAliOss(file, path, baseUrl, options, argument)
}
Qiniu-oss use:
import { uploadFileToQiniuOss } from 'file-utils-plus'
export const uploadFileToQiniuOss = async (file: File, path: string,baseUrl:string,token: string, argument?: Object) => {
return uploadFileToAliOss(file, path, baseUrl, token, argument)
}
Documentation
file
- get file md5
const getMd5: (file: File) => Promise<string>;
- get image attribute
const getImageAttribute: (file: File) => Promise<ImageSize>;
- check the file exists
const isExistFile: (url: string) => Boolean;
transform
- blob to file
const blobToFile: (blob: Blob, fileName: string, options: FilePropertyBag | undefined) => File;
- file to base64
const fileToBase64: (file: File) => Promise<string | null | ArrayBuffer | undefined>;
- base64 to blob
const base64ToBlob: (base64: string) => Promise<Blob>;
- base64 to File
const base64ToFile: (base64: string, filename: string) => Promise<File>;
- base64 to Buffer
const fileToBuffer: (files: Blob | File) => Promise<ArrayBuffer>;
ali-oss
- upload files to Ali oss
const uploadFileToAliOss: (file: File, path: string, baseUrl: string, options: AliOptions, argument?: any) => Promise<UploadInfo>;
qiniu-oss
- upload files to Qiniu oss
const uploadFileToQiniuOss: (file: File, path: string, baseUrl: string, token: string, argument?: any) => Promise<UploadInfo>;