首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >打开失败: EROFS (只读文件系统) android phonegap应用程序

打开失败: EROFS (只读文件系统) android phonegap应用程序
EN

Stack Overflow用户
提问于 2015-10-24 13:46:27
回答 1查看 2.2K关注 0票数 0

我正在尝试使用带有PhoneGap的Progress事件进行文件传输。

我的问题是,每当我按下下载按钮时,下面的错误就会出现。

我在这个链接下找到了代码并完整地复制了它:http://www.raymondcamden.com/2013/05/01/Using-the-Progress-event-in-PhoneGap-file-transfers

错误: 10-23 23:55:38.407 24464-24508/?E/文件传输:{“目标”:“//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”:“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 (只读文件系统)在java.io.FileOutputStream.(FileOutputStream.java:88) at org.apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi.java:329) at org的libcore.io.IoBridge.open(IoBridge.java:409).apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi.java:310) at org.apache.cordova.filetransfer.FileTransfer$4.run(FileTransfer.java:894) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:841)原因: libcore.io.ErrnoException: open失败: libcore.io.BlockGuardOs.open(BlockGuardOs.java:110) at libcore.io.IoBridge.open(IoBridge.java:393)的libcore.io.Posix.open(本机方法)的EROFS (只读文件系统);org.apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi的java.io.FileOutputStream.(FileOutputStream.java:88) (本地方法)的libcore.io.Posix.open(本地方法);org.apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi的org.apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi(本地方法);java.io.FileOutputStream.(FileOutputStream.java:88)的libcore.io.Posix.open(本地方法);org.apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi的libcore.io.IoBridge.open(本地方法);org.apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi的libcore.io.Posix.open(本地方法);org.apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi的libcore.io.IoBridge.open(本地方法);org.apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi的libcore.io.Posix.open(本地方法);org.apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi的libcore.io.IoBridge.open(本地方法);org.apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi的(本地方法);java.io.FileOutputStream.(FileOutputStream.java:88)的libcore.io.IoBridge.open(本地方法);org.apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi的(本地方法);java.io.FileOutputStream.(FileOutputStream.java:88)的libcore.io.IoBridge.open(本地方法);org.apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi的*。路透纽约8月23日电- org.apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi.java:310)的首席执行官、org.apache.cordova.filetransfer.FileTransfer$4.run(FileTransfer.java:894)的首席执行官、java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)的首席执行官、java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java的首席执行官、java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java的首席执行官,以及org.apache.cordova.filetransfer.FileTransfer$4.run(FileTransfer.java:894)的首席执行官、java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)的首席执行官、以及java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java的首席执行官(注:587) *(Thread.java:841)

index.html

代码语言:javascript
复制
<!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

代码语言:javascript
复制
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...');  
    });


}
EN

回答 1

Stack Overflow用户

发布于 2015-10-24 21:14:44

我找到了一个解决方案,我将完整路径改为root.toURL()。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33314953

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档