Update version to 3.0.0

- use MP3 instead of WAV
 - new callbacks & properties
 - refactoring
This commit is contained in:
Gennady Grishkovtsov
2018-12-16 23:28:36 +03:00
parent 7e89d8a33a
commit db90e87dff
16 changed files with 304 additions and 277 deletions

View File

@@ -3,16 +3,17 @@
</style>
<template>
<icon-button name="save" @click.native="upload"/>
<icon-button name="save" class="ar-icon ar-icon__xs ar-icon--no-border" @click.native="upload"/>
</template>
<script>
import IconButton from './icon-button'
import UploaderPropsMixin from '@/mixins/uploader-props'
export default {
mixins: [UploaderPropsMixin],
props: {
options : { type: Object },
record : { type: Object }
record: { type: Object }
},
components: {
IconButton
@@ -25,28 +26,16 @@
this.$eventBus.$emit('start-upload')
if (this.options.startUpload) {
this.options.startUpload()
}
const data = new FormData()
data.append('audio', this.record.blob, `${this.filename}.mp3`)
let data = new FormData()
data.append('audio', this.record.blob, 'my-record')
let headers = Object.assign(this.options.headers, {})
const headers = Object.assign(this.headers, {})
headers['Content-Type'] = `multipart/form-data; boundary=${data._boundary}`
this.$http.post(this.options.uploadUrl, data, { headers: headers }).then(resp => {
this.$eventBus.$emit('end-upload', 'success')
if (this.options.successfulUpload) {
this.options.successfulUpload(resp)
}
this.$http.post(this.uploadUrl, data, { headers: headers }).then(resp => {
this.$eventBus.$emit('end-upload', { status: 'success', response: resp })
}).catch(error => {
this.$eventBus.$emit('end-upload', 'fail')
if (this.options.failedUpload) {
this.options.failedUpload(error)
}
this.$eventBus.$emit('end-upload', { status: 'fail', response: error })
})
}
}