JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q43657F
  • License MIT

file-slice-upload

Package Exports

  • file-slice-upload
  • file-slice-upload/es/index.js
  • file-slice-upload/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (file-slice-upload) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

📄 File-Slice-Upload

Chinese

Quick Start

  1. Install
  • Use npm install
npm install file-slice-upload
  • Use yarn install
yarn add file-slice-upload
  1. Use file-slice-upload upload file's chunk
import fileUpload from 'file-slice-upload'
fileUpload()
.file(youFile, '1MB')
.uploadFunc(async(chunk)=>{
  const success = await postChunkFile(chunk)
  return success   /* return true will upload next chunk */
})
.start()

demo

  1. live-demo

Feature

  1. Easy to control the upload flow, help you focus on upload file logic !
  2. Friendly api .start() .stop() .continue()...
  3. More event start finish stop progress error...
  4. Tiny
  5. Use Typescript code

API document

export default

factory function,return the fileUpload instance

param type require description
parallel number - [1, 8] false every time send n file's chunks

fileUpload-class

  1. fileUpload.file(file, chunkSize, chunkName?) => this
param type require description
file File true the file's chunk
chunkSize String true chunk's size, for example: '200KB' '1MB' '2M'
chunkName (file: File, index: number) => string false return this chunk file's name
  1. fileUpload.uploadFunc(ajax) => this
param type require description
ajax (chunk: File | File[], index: number, chunks: File[] | File[][]) => Promise<any | true> true upload chunk function , return true will upload next chunk
  1. fileUpload.start() => this start upload

  2. fileUpload.stop() => this suspend upload

  3. fileUpload.continue() => this continue upload

  4. fileUpload.on(eventName, cb) => this listen event

  5. fileUpload.getFile() => file get file

  6. fileUpload.getChunkSize() => number get chunk size

eventName description callback function type
start start upload () => void
finish suspend upload (chunks: File[]) => void
continue continue upload () => void
progress upload progress ({done: number, all: number}) => void
chunk-uploaded chunk uploaded ({chunk: File, index: number, chunks: File[] }) => void
error upload fail () => void
  1. fileUpload.off(eventName, cb) => this close listen event