File system access: resolveLocalFileSystemURL fires FileError 5


#1

Hi All,

I need to download large video files and play them in future. We ported app from Cordova and everything works well except file system access, as we are starting app as file://.

So, the following simple test:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title>FS Test</title>
  </head>
  <body>
    <script>
        dataDirectory = "filesystem:file:///C:/temp/";
        window.webkitResolveLocalFileSystemURL(dataDirectory, function(directoryEntry) {
            console.log(directoryEntry);
        },
        function (e) {
            console.log(e)
        });
    </script>
  </body>
</html>

fires an error:

FileError
code: 5
message: "A URI supplied to the API was malformed, or the resulting Data URL has exceeded the URL length limitations for Data URLs."
name: "EncodingError"
__proto__: FileError

Please advise.


#2

What if you use dataDirectory = "file:///C:/temp/"; instead?


#3

Also does not work. I wanted to detect application directory for different platforms myself.
However, the following solutions works perfectly, and I hacked Cordova FileTransfer plugin to match the example below:

    window.webkitRequestFileSystem(window.PERSISTENT, 100500*1024*1024, function() {
        dataDirectory = "filesystem:file:///persistent/";
        window.webkitResolveLocalFileSystemURL(dataDirectory, function(directoryEntry) {
            console.log('success', directoryEntry);
        },
        function (e) {
            console.log(e);
        });
    },
    function (e) {
        console.log(e);
    });