1.1.35 • Published 2 years ago

chunks-upload v1.1.35

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

chunks upload

无任何依赖的大文件分片上传库,只需少量代码与所用前端框架(react,vue 等)响应式数据进行绑定即可。

install

npm i chunks-upload

use

以 vue 为例

import ChunkUpload from "chunks-upload";
import { initiateUpload, completeUpload } from "@/api";

export default ({
  sliceSize = 50 * 1024 * 1024,
  maxUploadNum = 2,
}: {
  sliceSize?: number;
  maxUploadNum?: number;
}) => {
  const loading = ref(false);
  const percentage = ref(0);
  const chunksUpload = new ChunkUpload(initiateUpload, completeUpload, {
    loading: (_loading) => {
      loading.value = _loading;
    },
    percentage: (_percentage) => {
      percentage.value = _percentage;
    },
  });
  chunksUpload.setChunkSize(sliceSize);
  chunksUpload.setMaxNum(maxUploadNum);
  const onUpload = (file: File) => {
    return chunksUpload.upload(file);
  };
  return {
    loading,
    percentage,
    onUpload,
  };
};
1.1.35

2 years ago

1.1.1

2 years ago

1.1.34

2 years ago

1.1.33

2 years ago

1.1.32

2 years ago

1.1.31

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.0.1

5 years ago

1.0.0

5 years ago