2.2.2 • Published 5 years ago
m-uploader-cos v2.2.2
Installing
Using npm
npm install m-uploader-cosUsing yarn
yarn add m-uploader-cosES6 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 ProxyCOSUploadUpload 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
5 years ago
2.2.1
5 years ago
2.2.0
5 years ago
2.1.8
5 years ago
2.1.7
5 years ago
2.1.6
5 years ago
1.1.6
5 years ago
1.1.5
5 years ago
1.1.4
5 years ago
1.1.3
5 years ago
1.1.2
5 years ago
1.1.0
5 years ago
1.0.8
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.2
5 years ago
1.0.3
5 years ago
1.0.1
5 years ago