webpack-alioss-upload-plugin
v1.5.1
Published
A webpack plugin to upload files to aliyun oss, which supports multiple optional upload method
Downloads
13
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
), defaultmultipart
, more info see here.uploadOptions
: [Object]parallel
: [Number] the number of parts to be uploaded in parallel, default4
.partSize
: [Number] the suggested size for each part inKB
, default204800
(200M), alioss's minimum partsize must larger than 100M.timeout
: [Number] the operation timeout in milliseconds, default6000
.retries
: [Number] retry times if multipart upload is interrupted, only work when uploadType ismultipart
useChunk
: [Boolean] whether or not usechunked encoding
, only work when uploadType isstream
, defaultfalse
, more info see here.
concurrency
: [Number] allow how many upload event to be created at the meanwhile, default3
, 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, defaultfalse
.
Contribution and Issues
Feel free to contribute code or publish an issue, whenever you have any good idea or find a bug.
License
Author
Javen Leung