1

I am trying to load a simple .txt file content with a Chrome App (using file: protocol); I need to show its content for the user in a <div>. I need to open the file from a path typed in a input text (or defined in a string variable).

The flag --allow-file-access-from-files works fine when I load my .txt file content through Chrome browser. However, when I try to do the same with my Chrome App launcher (I have applied --allow-file-access-from-files flag on it), it keeps telling

Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

I dont know if I am missing something or if it is impossible for chrome app. My user will work with the app in Windows platform.

Xan
  • 74,770
  • 16
  • 179
  • 206
angellica.araujo
  • 298
  • 1
  • 12
  • 2
    Use [chrome.fileSystem](https://developer.chrome.com/apps/fileSystem) instead. – Daniel Herr May 07 '16 at 19:09
  • Possible solutions are given in SO post - [How to launch html using Chrome at “--allow-file-access-from-files” mode?](http://stackoverflow.com/questions/18586921/how-to-launch-html-using-chrome-at-allow-file-access-from-files-mode) Hope it works for you too. :) – Teyam May 08 '16 at 09:44
  • Duplicate of http://stackoverflow.com/q/37029737/934239 - can't close since answer wasn't upvoted or accepted. – Xan May 09 '16 at 09:36
  • No, Xan. I don't think it is duplicate. The other question does not mention the flag at all. I finally figured out that the "--allow-file-access-from-files" does not work at all in my case. I started coding using fileSystem and made something like the recomended in this topic http://stackoverflow.com/questions/35209773/chrome-app-create-and-write-to-file ,following the main example https://github.com/GoogleChrome/chrome-app-samples/blob/master/samples/filesystem-access/js/app.js – angellica.araujo May 09 '16 at 12:10
  • It is a duplicate, in that the answer addresses your question ("can't use `file://` in apps" and proposes a solution) – Xan May 09 '16 at 12:16
  • 1
    Also - please don't edit questions to incorporate a "Solved: (solution)" part. It's perfectly fine to post an answer to your own question, and this will show others that the question HAS answers. – Xan May 09 '16 at 12:26
  • I accept it as a similar question as the other one that I have found since it does not make reference to the flag. There is references about using this flag but within the browser. I understand your point of view however my question cannot be answered by a question that does not mention the flag (my question title) in both body and comments. – angellica.araujo May 09 '16 at 12:28

1 Answers1

1

I finally figured out that --allow-file-access-from-files does not work at all in my case.

I started coding using fileSystem and made something like the recomended in this question, following the main example. Now I am able to work with files in a directory asking the user to choose it only one time.

Community
  • 1
  • 1
angellica.araujo
  • 298
  • 1
  • 12