我想從ngCordova的$ cordovaCapture服務上傳一個聲音文件到UploadCare。 uploadcare.fileFrom('object')保持失敗,出現'上傳'錯誤。我有公鑰集。我可以通過發送文件並標記和訪問document.getElementById('fileTag')。文件[0]來上傳文件。uploadcare文件來自ngCordova MediaFile
$cordovaCapture.captureAudio()
.then(function (audioData) {
return uploadcare.fileFrom('object', audioData[0])
.done(function (fileInfo) {
console.log(fileInfo);
}).fail(function (err) {
console.log(err);
})
})
的audioData [0]物體看起來像這樣
MediaFile {
end:0
fullPath:"file:/storage/emulated/0/Sounds/Voice%20002.m4a"
lastModified:null
lastModifiedDate:1481324751000
localURL:"cdvfile://localhost/sdcard/Sounds/Voice%20002.m4a"
name:"Voice 002.m4a"
size:49227
start:0
type:"audio/mpeg"
} __proto__:File
我想這個問題可能是該對象是一個媒體文件,而不是一個文件,但我可以利用一些幫助鑄造一方向另一方。
FileEntry
filesystem:FileSystem
fullPath:"/Sounds/Voice 002.m4a"
isDirectory:false
isFile:true
name:"Voice 002.m4a"
nativeURL:"file:///storage/emulated/0/Sounds/Voice%20002.m4a"
__proto__:Entry
File
end:49227
lastModified:1481324751000
lastModifiedDate:1481324751000
localURL:"cdvfile://localhost/sdcard/Sounds/Voice%20002.m4a"
name:"Voice 002.m4a"
size:49227
start:0
type:"audio/mpeg"
__proto__:Object
使用window.resolveLocalFileSystemUrl()你結束了,讓上面的文件對象,但uploadcare還是失敗,一個「上載」錯誤上述FileEntry的對象。