简体   繁体   English

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

[英]open failed: EROFS (Read-only file system) android phonegap app

I'm trying to use a Progress event with PhoneGap for file transfers. 我正在尝试将Progress事件与PhoneGap一起用于文件传输。

My problem is that every time when I press the download button, the errors below appear. 我的问题是,每当我按下下载按钮时,都会出现以下错误。

I found the code under this link and copied it completely: http://www.raymondcamden.com/2013/05/01/Using-the-Progress-event-in-PhoneGap-file-transfers 我在此链接下找到了代码,并将其完全复制: http : //www.raymondcamden.com/2013/05/01/Using-the-Progress-event-in-PhoneGap-file-transfers

Error: 10-23 23:55:38.407 24464-24508/? 错误:10-23 23:55:38.407 24464-24508 /? E/FileTransfer﹕ {"target":"//download.mp3","http_status":200,"code":1,"source":"http://archive.org/download/Kansas_Joe_Memphis_Minnie-When_Levee_Breaks/Kansas_Joe_and_Memphis_Minnie-When_the_Levee_Breaks.mp3","exception":"/download.mp3: open failed: EROFS (Read-only file system)"} java.io.FileNotFoundException: /download.mp3: open failed: EROFS (Read-only file system) at libcore.io.IoBridge.open(IoBridge.java:409) at java.io.FileOutputStream.(FileOutputStream.java:88) at org.apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi.java:329) at org.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) Caused by: libcore.io.ErrnoException: open failed: EROFS (Read-only 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(读为只要 file system) at libcore.io.Posix.open(Native Method) at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110) at libcore.io.IoBridge.open(IoBridge.java:393) at java.io.FileOutputStream.(FileOutputStream.java:88) at org.apache.cordova.CordovaResourceApi.openOutputStream(CordovaResourceApi.java:329) at org.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.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 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 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.

相关问题 DialogFlow Webhook:错误:EROFS:只读文件系统,打开“ .node-xmlhttprequest-sync-2” - DialogFlow Webhook : Error: EROFS: read-only file system, open '.node-xmlhttprequest-sync-2' GAE 上的 NextJS - 错误:EROFS:只读文件系统 - NextJS on GAE - Error: EROFS: read-only file system Google 云函数部署:EROFS:只读文件系统 - Google Clould Functions deploy: EROFS: read-only file system Electron - 创建文件时出现问题,错误“EROFS:只读文件系统” - Electron - problem creating file, error “EROFS: read-only file system” 错误:EROFS:在 Lambda 中流式传输 xlsx 内容时只读文件系统 - Error: EROFS: read-only file system while streaming the xlsx content in Lambda 使用FileOpener Phonegap Android出现“未定义”结果,并且无法打开视频文件吗? - “undefined” result using FileOpener Phonegap Android and failed to open video File? Android Webkit中的只读输入不起作用 - Read-only input in Android Webkit not working eslint erofs 只读 - 不匹配任何目录 - eslint erofs read only- doest not match with any directory 只读属性 - read-only property PhoneGap + AngularJS无法读取刚刚创建的文件 - PhoneGap + AngularJS failed to read file that is just created
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM