[英]DialogFlow Webhook : Error: EROFS: read-only file system, open '.node-xmlhttprequest-sync-2'
[英]open failed: EROFS (Read-only file system) android phonegap app
我正在嘗試將Progress事件與PhoneGap一起用於文件傳輸。
我的問題是,每當我按下下載按鈕時,都會出現以下錯誤。
我在此鏈接下找到了代碼,並將其完全復制: http : //www.raymondcamden.com/2013/05/01/Using-the-Progress-event-in-PhoneGap-file-transfers
錯誤:10-23 23:55:38.407 24464-24508 /? E / FileTransfer:{“目標”:“ // download.mp3”,“ http_status”:200,“代碼”:1,“源”:“ http://archive.org/download/Kansas_Joe_Memphis_Minnie-When_Levee_Breaks/Kansas_Joe_and_Memphis_Minnie- when_the_Levee_Breaks.mp3“,” exception“:” / download.mp3:打開失敗:EROFS(只讀文件系統)“} java.io.FileNotFoundException:/download.mp3:打開失敗:EROFS(只讀文件系統)在libcore.io.IoBridge.open(IoBridge.java:409)在org.apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi.java:329)在java.io.FileOutputStream。(FileOutputStream.java:88)在org.apache org.apache.cordova.filetransfer.FileTransfer $ 4.run(FileTransfer.java:894)處的.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi.java:310)在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)在java.lang.Thread.run(Thread.java:841)處java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:587)原因:libcore.io.ErrnoException:打開失敗:EROFS(讀為只要 文件系統),位於libcore.io.Posix.open(本機方法),位於libcore.io.BlockGuardOs.open(BlockGuardOs.java:110),位於libcore.io.IoBridge.open(IoBridge.java:393),位於java.io.位於org.apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi.java:329)的org.apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi.java:310)的FileOutputStream。(FileOutputStream.java:88)。文件傳輸.FileTransfer $ 4.run(FileTransfer.java:894)在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:587)在java.lang.Thread.run(Thread.java:841)
index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name = "format-detection" content = "telephone=no"/>
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>FileTransfer Test</title>
</head>
<body>
<div id="content">
<p>
Kansas Joe McCoy and Memphis Minnie – "When The Levee Breaks"
</p>
<img src="img/KansasJoeAndMemphisMinnie.jpg">
<p>
<button id="startDl">Click to Download and Play</button>
</p>
</div>
<div id="status"></div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/app.js"></script>
</body>
</html>
app.js
document.addEventListener('deviceready', deviceready, false);
var buttomDom;
var statusDom;
var fileSystem;
function deviceready() {
console.log('dv ready');
//step one is to request a file system
window.requestFileSystem(LocalFileSystem.TEMPORARY, 0,
function(fs) {
fileSystem = fs;
buttonDom = document.querySelector('#startDl');
buttonDom.addEventListener('touchend', startDl, false);
buttonDom.removeAttribute("disabled");
statusDom = document.querySelector('#status');
}, function(e) {
alert('failed to get fs');
alert(JSON.stringify(e));
});
}
function startDl() {
buttonDom.setAttribute("disabled","disabled");
var ft = new FileTransfer();
var uri = encodeURI("http://archive.org/download/Kansas_Joe_Memphis_Minnie-When_Levee_Breaks/Kansas_Joe_and_Memphis_Minnie-When_the_Levee_Breaks.mp3");
var downloadPath = fileSystem.root.fullPath + "/download.mp3";
ft.onprogress = function(progressEvent) {
if (progressEvent.lengthComputable) {
var perc = Math.floor(progressEvent.loaded / progressEvent.total * 100);
statusDom.innerHTML = perc + "% loaded...";
} else {
if(statusDom.innerHTML == "") {
statusDom.innerHTML = "Loading";
} else {
statusDom.innerHTML += ".";
}
}
};
ft.download(uri, downloadPath,
function(entry) {
statusDom.innerHTML = "";
var media = new Media(entry.fullPath, null, function(e) { alert(JSON.stringify(e));});
media.play();
},
function(error) {
alert('Crap something went wrong...');
});
}
我找到了解決方案,將完整路徑更改為root.toURL()。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.