Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
119
rated 0 times [  126] [ 7]  / answers: 1 / hits: 27560  / 6 Years ago, thu, august 2, 2018, 12:00:00

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.




`


More From » file

 Answers
143

Try



const blob = new Blob([file],{type: 'audio/m4u'})

[#53823] Monday, July 30, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
malkajillc

Total Points: 652
Total Questions: 107
Total Answers: 98

Location: Finland
Member since Sat, Nov 6, 2021
3 Years ago
malkajillc questions
;