1.5.1 • Published 5 years ago

webpack-alioss-upload-plugin v1.5.1

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

webpack-alioss-upload-plugin

A flexible webpack plugin to upload files to aliyun oss, which supports multiple optional upload methods and parameters.

This plugin only works with webpack version above 4.0

Advantages

  • Supports 3 alternative upload methods that aliyun oss supports.

  • Supports multipart upload and retries at the breakpoints.

  • Can custom timeout to drop the request.

  • Can control how many http request threads are created at the meanwhile. Too many threads may result in an error returned from aliyun.

  • Can switch debug mode to decide whether or not showing verbose log.

Installation

npm i webpack-alioss-upload-plugin -D

or

yarn add webpack-alioss-upload-plugin -D

Usage

Here is a simplest usage.

const AliOSSUploadPlugin = require("webpack-alioss-upload-plugin");
// webpack config
module.exports = {
  plugins: [
    new AliOSSUploadPlugin({
      accessKeyId: "your.oss.accessKeyId",
      accessKeySecret: "your.oss.accessKeySecret",
      region: "your.oss.region",
      bucket: "your.oss.bucket"
    })
  ]
};

Options

  • accessKeyId:Stringthe accessKeyId of your oss, required.
  • accessKeySecret:Stringthe accessKeySecret of your oss, required.
  • region:Stringthe region of your oss, required.
  • bucket:Stringthe bucket name of your oss, required.
  • prefix:Stringthe path to direct to files on oss, if configured, it looks like "https://${bucket}.${region}.aliyuncs.com/${prefix}/local-resolved-file-name", default ''.
  • uploadType:Stringhas three types(put|stream|multipart), corresponding to alioss's upload methods(put|putStream|multipart), default multipart, more info see here.
  • uploadOptions:Object
    • parallel:Numberthe number of parts to be uploaded in parallel, default 4.
    • partSize:Numberthe suggested size for each part in KB, default 204800(200M), alioss's minimum partsize must larger than 100M.
    • timeout:Numberthe operation timeout in milliseconds, default 6000.
    • retries:Numberretry times if multipart upload is interrupted, only work when uploadType is multipart
    • useChunk:Booleanwhether or not use chunked encoding, only work when uploadType is stream, default false, more info see here.
  • concurrency:Numberallow how many upload event to be created at the meanwhile, default 3, may your system may crash if this parameter is too large.
  • excludes:[RegExp|ArrayRegExp]files not wanting to upload to oss, default [].
  • debug:Booleanwhether or not show verbose log on command line, default false.

Contribution and Issues

Feel free to contribute code or publish an issue, whenever you have any good idea or find a bug.

License

MIT

Author

Javen Leung

1.5.1

5 years ago

1.5.0

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago