mirror of
https://github.com/kevin-DL/vue-audio-recorder.git
synced 2026-01-20 06:25:12 +00:00
Update version to 3.0.0
- use MP3 instead of WAV - new callbacks & properties - refactoring
This commit is contained in:
@@ -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 })
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user