upload-oss-cloud
v0.0.17
Published
A package for uploading file to ali oss with vue component and iview library
Downloads
5
Maintainers
Readme
installation
npm i upload-oss-cloud
Demo
/**
* The others props of component cases is same as iview upload, owner props is here.
*/
<template>
<upload-oss-cloud
v-model="files"
:action="action"
:access-key-id="accessKeyId"
:access-key-secret="accessKeySecret"
:policy="policy"
:signature="signature"
:directory="directory"
:image="image"
:video="video"
:stop="stop"
@upload="upload"
@preview="preview"
@remove="remove"
/>
</template>
<script>
import UploadOssCloud from 'upload-oss-cloud'
Vue.use(UploadOssCloud) || Vue.component(UploadOssCloud.name, UploadOssCloud)
export default {
data() {
files: [],
action: 'http://xxx.example.com', // upload details
accessKeyId: '', // upload details
accessKeySecret: '', // upload details
policy: '', // upload details
signature: '', // upload details
directory: '', // upload directory start without slash
image: false, // shortcut for upload image file
video: false, // shortcut for upload video file
stop() {
// Falsy or rejection promise can stop upload
return true
}
},
methods: {
upload({status, file, percentage, error}) {
/**
* status = -1 | 0 | 1 | 2 => error | before | progress | success
*/
console.log(status, file, percentage, error)
},
preview(file) {
// File is previewed
console.log(file)
},
remove(file) {
// File is removed
console.log(file)
}
}
}
</script>