0.3.24 • Published 5 years ago

file-chunk-upload v0.3.24

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

file-chunk-upload

Installation

npm install file-chunk-upload

Import

  • ESM
import FileUploader from 'file-chunk-upload'
  • CommonJS
var FileUploader = require('file-chunk-upload')
  • CDN
<script src="https://unpkg.com/file-chunk-upload/dist/file-chunk-upload.min.js"></script>

Usage

var fileUploader = new FileUpload({
  // The first size of a file(in B) to breakpoint resume
  firstSize: 256 * 1024,
  // The size of a chunk(in B)
  chunkSize: 4 * 1024 * 1024,
  // The time of expiration
  expiration: 24 * 60 * 60,
  // Number of concurrent uploads
  maxConcurrent: 2,
  // Auto file upload
  autoUpload: true,
  // The url of prepare to upload
  prepareUrl: '/file/prepare',
  // The url of uploading every chunk
  uploadUrl: '/file/upload',
  // The url of checking md5
  checkUrl: '/file/check',
  // The url of merging file
  mergeUrl: '/file/merge',
  // The request headers
  headers: {},
  // The number of reupload the chunk if fail
  reupload: 5,
  // Upload success callback
  success: function(fileObj, response) {
    console.log(response);
  },
  // Upload error callback
  error: function(fileObj, error, type) {
    console.log(error, type);
  },
  // Upload progress callback
  progress: function(fileObj) {
    console.log(fileObj.percentage);
  }
});
// add File to fileUploader
var fileObj = fileUploader.addFile(file);
// if autoUpload is false
fileUploader.upload(fileObj);
// pause upload
fileUploader.pause(fileObj);
// continue upload
fileUploader.continue(fileObj);
// remove file
fileUploader.remove(fileObj);

Example

npm install
npm run dev
0.3.24

5 years ago

0.3.23

5 years ago

0.3.22

5 years ago

0.3.21

5 years ago

0.3.19

5 years ago

0.3.18

5 years ago

0.3.16

5 years ago

0.3.15

5 years ago

0.3.14

5 years ago

0.3.13

5 years ago

0.3.12

5 years ago

0.3.11

5 years ago

0.3.10

5 years ago

0.3.9

5 years ago