[英]Read file with FileReader from a Samsung
I'm having trouble trying to read a File width FileReader from a Samsung. 我在尝试从Samsung读取文件宽度FileReader时遇到麻烦。 With other devices it works fine.
与其他设备一起正常工作。
This is the reader service script: 这是读者服务脚本:
function readFileAsync(file) {
var p = $q.defer();
var reader = new FileReader();
reader.onload = function(event) {
console.log('[FileReader] Success in read ' + JSON.stringify(event));
//var byteFile = new Int8Array(event.target.result);
//p.resolve(byteFile);
p.resolve(event.target.result);
};
reader.onabort = function(reason) {
console.log('[FileReader] abort ' + JSON.stringify(reason));
p.reject(reason);
reader.abort();
}
reader.onerror = function(err) {
console.log('[FileReader] ' + JSON.stringify(err));
p.reject(err);
};
// for ios
var localFileURL = file.fullPath.indexOf('file:/') == 0 ? file.fullPath : 'file://' + file.fullPath;
window.resolveLocalFileSystemURL(localFileURL, function (fileEntry) {
fileEntry.file(function (validFile) {
reader.readAsArrayBuffer(validFile);
});
});
return p.promise;
}
This is the argument "file": 这是参数“文件”:
{
"name": "20161201_134758.mp4",
"localURL": "cdvfile://localhost/sdcard/DCIM/Camera/20161201_134758.mp4",
"type": "video/mp4",
"lastModified": null,
"lastModifiedDate": 1480610881000,
"size": 5464040,
"start": 0,
"end": 0,
"fullPath": "file:/storage/emulated/0/DCIM/Camera/20161201_134758.mp4"
}
And here is the error that outouts in 'onerror' event: 这是在“ onerror”事件中出现的错误:
{
"type": "error",
"bubbles": false,
"cancelBubble": false,
"cancelable": false,
"lengthComputable": false,
"loaded": 0,
"total": 0,
"target": {
"_readyState": 2,
"_error": {
"code": 1
},
"_result": null,
"_progress": 0,
"_localURL": "cdvfile://localhost/sdcard/DCIM/Camera/20161201_134758.mp4",
"_realReader": {}
}
}
I'm stuck with this so any advice will help. 我坚持这样做,所以任何建议都会有所帮助。 Thanks
谢谢
只需从我的手机添加权限... facepalm
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.