ebidel / filer.js

A wrapper library for the HTML5 Filesystem API what reuses UNIX commands (cp, mv, ls) for its API.
Other
1.49k stars 155 forks source link

self.requestFileSystem returns SecurityError when running as a Chrome App. #71

Open benawarez opened 5 years ago

benawarez commented 5 years ago

filer.js works awesome in Chrome. However, when loaded as a Chrome App, I get SecurityError with the message "It was determined that certain files are unsafe for access within a Web Application, or that too many calls are being made on file resources." when invoking self.requestFileSystem in the following lines for both Temporary and Persistent.

image

Line 453 and 457 is the one throwing an error.

I have Chrome browser version 74+ which works great on Windows and Chromebook.

Issue is when running it as a Chrome App on the same Chromebook where it works fine on Chrome browser.

From debugging, self.requestFileSystem is undefined so it uses self.webkitRequestFileSystem instead.

I've been trying to figure this out for days and I can't get rid of that SecurityError.

Please help.

Below is my Chrome App manifest.json:

{ "name": "Signage Player", "version": "0.1", "manifest_version": 2, "minimum_chrome_version": "37.0.0.0", "permissions": [ "webview", "power", "storage", "videoCapture", "geolocation", "pointerLock", "system.display", "syncFileSystem", "webNavigation", "fileSystem", "fileSystem.write", "fileSystem.requestFileSystem", "fileSystem.retainEntries", "fileSystem.directory", "accessibilityFeatures.read", "accessibilityFeatures.modify" ], "app": { "background": { "scripts": [ "js/foam.js", "js/cab.js", "config.js", "background_main.js" ] } }, "kiosk_enabled": true, "default_locale": "en", "icons": { "128": "img/Signage-128.png" } }

ebidel commented 5 years ago

I think you need to use the chrome specific filesystem apis in a chrome app.

https://developer.chrome.com/apps/fileSystem

On Mon, Jun 17, 2019, 6:49 AM benawarez notifications@github.com wrote:

filer.js works awesome in Chrome. However, when loaded as a Chrome App, I get SecurityError with the message "It was determined that certain files are unsafe for access within a Web Application, or that too many calls are being made on file resources." when invoking self.requestFileSystem in the following lines for both Temporary and Persistent.

[image: image] https://user-images.githubusercontent.com/14115278/59578845-c4eb7880-908f-11e9-9233-7beafb9beac8.png

Line 453 and 457 is the one throwing an error.

I have Chrome browser version 74+ which works great on Windows and Chromebook.

Issue is when running it as a Chrome App on the same Chromebook where it works fine on Chrome browser.

From debugging, self.requestFileSystem is undefined so it uses self.webkitRequestFileSystem instead.

I've been trying to figure this out for days and I can't get rid of that SecurityError.

Please help.

Below is my Chrome App manifest.json:

{ "name": "Signage Player", "version": "0.1", "manifest_version": 2, "minimum_chrome_version": "37.0.0.0", "permissions": [ "webview", "power", "storage", "videoCapture", "geolocation", "pointerLock", "system.display", "syncFileSystem", "webNavigation", "fileSystem", "fileSystem.write", "fileSystem.requestFileSystem", "fileSystem.retainEntries", "fileSystem.directory", "accessibilityFeatures.read", "accessibilityFeatures.modify" ], "app": { "background": { "scripts": [ "js/foam.js", "js/cab.js", "config.js", "background_main.js" ] } }, "kiosk_enabled": true, "default_locale": "en", "icons": { "128": "img/Signage-128.png" } }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ebidel/filer.js/issues/71?email_source=notifications&email_token=AAB2FAHCNM3MIAXRUZKSZTLP24JWXA5CNFSM4HYTEIEKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GZZKGGA, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB2FAB25L732N7TNOANCZDP24JWXANCNFSM4HYTEIEA .

benawarez commented 5 years ago

I was thinking and trying to figure that out by reading the documentation but it wasn't very clear. I do know the requestFileSystem parameters are different but when I used the Chrome App Builder wizard to create the manifest and all other dependencies, one of the file is called foam.js and it had the following line of codes: image

which essentially looked exactly like line 29 from filer.js image

back to the foam.js, requestFileSystem takes the same type of parameters as filer.js is taking: image

and foam.js and I can confirm that the foam.js gets executed because it is in the manifest.json and I'm able to see it in developers console when the app launches.

Just last night... I'm beginning to suspect that I'm getting a SecurityError because a remote website that is executing the requestFileSystem instead of the source executing is from within the app like the one in the foam.js.

I'll test.