I'm recording an audio into an empty file using Cordova Media.
To upload it I need to have the content type on the file.
I'm trying to convert the File into a Blob so I can set the content type, however I'm struggling to convert the File into a blob
state.cordova.localDirectory.getFile(filename,{create:true, exclusive:false},
f => {
const options = {
SampleRate: 16000,
NumberOfChannels: 1,
}
media = new window.Media(f.nativeURL,() =>
f.file(file => {
const blob = new Blob(file,{type: 'audio/m4u'}) <-- Trying to convert file into a blob here
blob.lastModifiedDate = new Date()
blob.name = filename
console.log(blob)
upload(blob,'audio/m4u')
.then(data=> {console.log(data);store.dispatch(voiceAudioUploaded(sessionId,gameTaskId,data))}, err=> console.log(err))
}
, err => console.log('err',err) ))
media.startRecordWithCompression(options)
})
Error is `
Failed to construct 'Blob': Iterator getter is not callable.
`
Try
const blob = new Blob([file],{type: 'audio/m4u'})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With