2.2.2 • Published 3 years ago
m-uploader-cos v2.2.2
Installing
Using npm
npm install m-uploader-cos
Using yarn
yarn add m-uploader-cos
ES6 import
import COSUpload from 'm-uploader-cos'
Use examples
Proxy interception
const handler = { construct(target, args) { const { headers = {}, ...config } = args[0] config.headers = Object.assign(headers, { 'Authorization': localStorage.getItem('AUTH-TOKEN') }) return new target(config) } } const ProxyCOSUpload = new Proxy(COSUpload, handler) export default ProxyCOSUpload
Upload files directly
const COSUploader = new COSUpload({ pickId: 'selector', // id selector tmpKeyUrl: '/api/upload/tmpKey' // Get cos related configuration items through server interface }) COSUploader.$on('getUploadFileInfo', filesInfo => { console.log('uploadFileInfo', filesInfo) })
Note: through getUploadFileInfo to get the file information for other operations, such as MD5 encryption
Preview local files before uploading
const COSUploader = new COSUpload({ pickId: 'selector', tmpKeyUrl: '/api/upload/tmpKey', isPreview: true, }) COSUploader.$on('getPreviewFileInfo', filesInfo => { console.log('previewFileInfo', filesInfo) }) COSUploader.$on('getUploadFileInfo', filesInfo => { console.log('uploadFileInfo', filesInfo) }) COSUploader.handleUpload(uploadFiles)
Get upload progress and rate
const COSUploader = new COSUpload({ pickId: 'selector', tmpKeyUrl: '/api/upload/tmpKey', getProgress({ percentage, speed }) { console.log(`Upload progress:${percentage}`) console.log(`Upload rate:${speed}`) } })
2.2.2
3 years ago
2.2.1
3 years ago
2.2.0
3 years ago
2.1.8
3 years ago
2.1.7
3 years ago
2.1.6
3 years ago
1.1.6
3 years ago
1.1.5
3 years ago
1.1.4
3 years ago
1.1.3
3 years ago
1.1.2
3 years ago
1.1.0
3 years ago
1.0.8
3 years ago
1.0.6
3 years ago
1.0.5
3 years ago
1.0.4
3 years ago
1.0.2
3 years ago
1.0.3
3 years ago
1.0.1
3 years ago