File API

Bug #1591761 reported by costales
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Oxide
Incomplete
Undecided
Unassigned

Bug Description

Hi,
I think the HTML5 File API is not working in oxide (?).
Thanks in advance!

Revision history for this message
Olivier Tilloy (osomon) wrote :

What specifically in the File API is not working for you? Can this bug be marked a duplicate of bug #1490749 maybe?

Changed in oxide-qt (Ubuntu):
status: New → Incomplete
affects: oxide-qt (Ubuntu) → oxide
Revision history for this message
Olivier Tilloy (osomon) wrote :

I just tested http://html5demos.com/file-api in webbrowser-app on my desktop (unity7), and dropping an image file onto the target fails to display it, I’m seeing the following error in the console:

qml: [JS] (http://html5demos.com/file-api:48) undefined
qml: [JS] (http://html5demos.com/file-api:49) Uncaught TypeError: Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'.

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

This is more likely a drag and drop issue

Revision history for this message
costales (costales) wrote : [Bug 1591761] Re: File API

Hi Olivier,

I would like to load/save files in the application uwriter for Ubuntu Phone.
https://uappexplorer.com/app/uwp.costales

In my tests on phone the API is always returning an error. I was trying
this API (it has a good demo):
http://blog.teamtreehouse.com/building-an-html5-text-editor-with-the-filesystem-apis

The code is this and it's working if I load the uwp/index.html in chromium,
but on phone always return in the errorHandler a SECURITY_ERR error:

window.requestFileSystem = window.requestFileSystem ||
window.webkitRequestFileSystem;
// Create a variable that will store a reference to the FileSystem.
if (window.requestFileSystem) {
    initFileSystem();
} else {
    alert('Your browser doesn\'t support the FileSystem API');
}

function initFileSystem() {
navigator.webkitPersistentStorage.requestQuota(1024 * 1024 * 5,
  function(grantedSize) {

    // Request a file system with the new size.
    window.requestFileSystem(window.PERSISTENT, grantedSize, function(fs) {

      // Set the filesystem variable.
      filesystem = fs;
      console.log('OK!');
    }, errorHandler);

  }, errorHandler);
}

function errorHandler(error) {
    console.log('>>> '+error.name +': '+ error.message);
}

--
--
Sent using Dekko from my Ubuntu device

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

I'm confused. Are you reporting a bug with the file API (FileList, File, FileReader)? Or the filesystem API?

Revision history for this message
Olivier Tilloy (osomon) wrote :

I guess that’s a duplicate of bug #1436010 then?

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

Not in this case - requestQuota will grant 5MB without requesting permission.

But the filesystem API won't work from file: URLs, as there's no origin. It doesn't work in Chrome from file: URLs either unless you weaken its security by running it with --allow-file-access-from-files

Revision history for this message
costales (costales) wrote :

Hi,

> URLs either unless you weaken its security by running it with --allow-file-access-from-files

My webview is embebed by a QML and I had allowed these parameters
(http://bazaar.launchpad.net/~costales/uwriter/trunk/view/head:/qml/Main.qml):

            preferences.localStorageEnabled: true
            preferences.allowFileAccessFromFileUrls: true
            preferences.allowUniversalAccessFromFileUrls: true

then, the webview should can to write files (?).

Thanks a lot!

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

Those won't help here - this can only be enabled by passing a global flag to Chromium.

allowFileAccessFromFileUrls and allowUniversalAccessFromFileUrls are foot-guns - they're really dangerous options and we shouldn't be relying on them in any shipping code. We need to figure out a better way to run local HTML applications that doesn't depend on file URLs and doesn't use the webview (which is a poor fit for your use-case anyway)

Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

@chris: dont we have a bug for that already (defining an approach for local file access not based on file URI) ? I remember us discussing it,

Revision history for this message
Olivier Tilloy (osomon) wrote :

I believe that’s bug #1410919.

Revision history for this message
costales (costales) wrote :

But then, could I do something from a HTML app now for allowing read/write a file?
Thanks!

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

You can't - I've got some ideas to actually deprecate WebView entirely for local HTML applications (eg, bug 1593697 as a starting point).

Revision history for this message
costales (costales) wrote :

> to actually deprecate WebView entirely for local HTML applications

What? :O I think the ~30% of the apps (not webapps) in the Store is
based in a webview container.

If Ubuntu sold HTML5 apps as development option, IMHO they should have
a real HTML5 environment with all options. As example, uWriter could
be a great word processor, but without save files, it's just a weird
app.

The security is not an issue for me, because the apps are isolated.

Best regards.

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

Oh, the idea is to provide something better than WebView for local apps

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.