我使用离子与cordova-plugin-media录制音频,我想使用angular-file-upload上传录制到服务器的音频,但我不知道如何从Media获取文件.我试试这个:
控制器:
$scope.itemOnLongPress = function (id) {;
myMedia = new Media("./sound/recorded.wav");
myMedia.startRecord();
}
$scope.itemOnTouchEnd = function (id) {
myMedia.stopRecord();
myMedia.play();
window.resolveLocalFileSystemURI(myMedia.src,
// success callback; generates the FileEntry object needed to convert to Base64 string
function (fileEntry) {
// convert to Base64 string
function win(file) {
var reader = new FileReader();
reader.onloadend = function (evt) {
var obj = evt.target.result; // this is your Base64 string
alert(obj);
};
reader.readAsDataURL(file);
};
var fail = function (evt) {};
fileEntry.file(win, …Run Code Online (Sandbox Code Playgroud)