wau
webpack-alioss-upload-plugin
npm i webpack-alioss-upload-plugin
wau

webpack-alioss-upload-plugin

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

by Javen Leung

1.5.1 (see all)License:MITTypeScript:Not Found
npm i webpack-alioss-upload-plugin
Readme

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: [String] the accessKeyId of your oss, required.
  • accessKeySecret: [String] the accessKeySecret of your oss, required.
  • region: [String] the region of your oss, required.
  • bucket: [String] the bucket name of your oss, required.
  • prefix: [String] the path to direct to files on oss, if configured, it looks like "https://${bucket}.${region}.aliyuncs.com/${prefix}/local-resolved-file-name", default ''.
  • uploadType: [String] has three types(put|stream|multipart), corresponding to alioss's upload methods(put|putStream|multipart), default multipart, more info see here.
  • uploadOptions: [Object]
    • parallel: [Number] the number of parts to be uploaded in parallel, default 4.
    • partSize: [Number] the suggested size for each part in KB, default 204800(200M), alioss's minimum partsize must larger than 100M.
    • timeout: [Number] the operation timeout in milliseconds, default 6000.
    • retries: [Number] retry times if multipart upload is interrupted, only work when uploadType is multipart
    • useChunk: [Boolean] whether or not use chunked encoding, only work when uploadType is stream, default false, more info see here.
  • concurrency: [Number] allow 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|Array[RegExp]] files not wanting to upload to oss, default [].
  • debug: [Boolean] whether 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

Downloads/wk

10

GitHub Stars

14

LAST COMMIT

1yr ago

MAINTAINERS

1

CONTRIBUTORS

2

OPEN ISSUES

0

OPEN PRs

2
VersionTagPublished
1.5.1
latest
3yrs ago
No alternatives found
No tutorials found
Add a tutorial

Rate & Review

100
No reviews found
Be the first to rate