Options
All
  • Public
  • Public/Protected
  • All
Menu

Module File

文件处理相关

Index

Type aliases

FileSizeUnit

FileSizeUnit: "B" | "KB" | "MB" | "GB" | "TB"

Method

Method: "get" | "GET" | "delete" | "DELETE" | "head" | "HEAD" | "options" | "OPTIONS" | "post" | "POST" | "put" | "PUT" | "patch" | "PATCH" | "link" | "LINK" | "unlink" | "UNLINK"

Functions

blobToDataURL

  • blobToDataURL(blob: Blob): any
  • Parameters

    • blob: Blob

    Returns any

calcFileSize

  • 计算文件大小

    使用说明

    calcFileSize(100) 返回 { size: 100, unit: 'B' }
    calcFileSize(1024) 返回 { size: 1, unit: 'KB' }
    calcFileSize(1024, 'KB') 返回 { size: 1, unit: 'MB' }
    calcFileSize(1126.4, 'mb') 返回 { size: 1.1, unit: 'GB' }
    calcFileSize(Math.pow(1024, 2), 'kb') 返回 { size: 1, unit: 'GB' }

    Parameters

    • size: number

      单位 k

    • Default value unit: FileSizeUnit = "B"

    Returns FileSizeObject

    number

compressImg

dataURLtoBlob

  • dataURLtoBlob(dataurl: string): Blob
  • base64转换为file dataurl base64图片

    Parameters

    • dataurl: string

    Returns Blob

fileSizeFormat

  • fileSizeFormat(str: string | number, unit?: FileSizeUnit, defaultValue?: string): string
  • 文件大小转换

    使用说明

    fileSizeFormat('') 返回 -
    fileSizeFormat('1024') 返回 1KB
    fileSizeFormat('1024', 'KB') 返回 1MB
    fileSizeFormat('2645', 'B') 返回 ceil(2645 / 1024, 2)MB

    Parameters

    • str: string | number

      字符串 单位k

    • Default value unit: FileSizeUnit = "B"
    • Default value defaultValue: string = "-"

    Returns string

genExportByBlob

  • genExportByBlob(__namedParameters: { axiosRequest: any; notWithCredentials: never[] }): exportByBlob
  • 生成导出函数

    Parameters

    • __namedParameters: { axiosRequest: any; notWithCredentials: never[] }
      • axiosRequest: any
      • notWithCredentials: never[]

    Returns exportByBlob

Generated using TypeDoc