How to load local files from user selected directory in chrome app - google-chrome-app

I am developing chrome app , in my app user can download external content to their local directory , to access user's file system i am using chrome.FileSystem API ,i can access user's local directory and i am also able to write downloaded content to their directory by keeping user selected directory to localStorage.
My problem is i want to open these files in main html file using either webview / iframe , it will be better if its possible with iframe but i am getting error in both cases -
to get full path i am using below code -
chrome.fileSystem.getDisplayPath(chosenEntry, function(path) {
console.log("path"+path);
// for now i am adding static path to it for testing purpose
var finalPath = path+'/folder/index.html'; //Here finalPath is a valid path , can be accessible from browser
});
if i load it using iFrame -
Refused to frame 'path' because it violates the following Content Security Policy directive: "frame-src 'self' blob: filesystem: data: chrome-extension-resource:".
When i tried using webview -
: The load has aborted with error -301: ERR_DISALLOWED_URL_SCHEME.
I have also tried by giving permission in manifest.json file -
"permissions": [
"file:///*"
]
Note : user may have number of downloaded content each with their own folder , so i have to open any of these according to user action.

It's not the most elegant solution, but running a web server inside chrome your chrome app and pointing the webview at the web server URL will work.

Related

Load Audio from persistentDataPath in runtime (Unity3d WebGL)

I have online/offline project.
I need to download wav/ogg/mp3 file from Application.persistentDataPath on WebGL platform.
I tried www/webrequest.
For example - WWW("file://" + Application.persistentDataPath + filePath);
But always get error: Failed to load: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
Could you help me?
P.S. From remote server works fine.
You can not load local files in a browser as it's a security risk. If you could then a webpage could read your hard drive and steal all your files.
If you're just testing you can run a local server.
If you want to let the user supply a file you can let them choose a file

Google PHP AppEngine - Deployment Issue with PHP file not being uploaded

I have a very simple PHP app that allows a User to enter names of Cities or Zip-codes into a search box, and the User gets auto-complete suggestions based on data stored in my Google CloudSQL server.
index.html - Renders a simple search box where users can enter search keys and they get auto-complete suggestions. Accomplished via Twitter's typeahead.js library (jQuery plugin).
city.php - PHP file that acts as a translation layer. Receives request from the browser and initiates connection to my Google CloudSQL server where I have a simple database with some city and zipcode data. Returns the data back to the browser as an array.
This works on my local Mac OS X Apache server. I am trying to get this setup to work on Google PHP AppEngine. I created an app.yaml file that looks like this:
runtime: php55
api_version: 2
threadsafe: true
handlers:
- url: /
static_files: index.html
upload: index.html
- url: /(.*)
static_files: www/\1
upload: (.*)
- url: /(.+\.php)$
script: \1
This is where I run into an issue. When I run gcloud app deploy from my local folder (which houses index.html, city.php, and app.yaml), I get the following message in the logs.
Some files were skipped. Pass `--verbosity=info` to see which ones.
You may also view the gcloud log file, found at
[/Users/arjunshah/.config/gcloud/logs/2016.11.13/12.31.04.137587.log].
When I run gcloud app deploy with log verbosity, I see the following:
INFO: Could not find any remote repositories associated with [/Users/arjunshah/Documents/autocomplete]. Cloud diagnostic tools may not be able to display the correct source code for this deployment.
File upload done.
INFO: Manifest: [{'app.yaml': {'sourceUrl': 'https://storage.googleapis.com/staging.ashah-146101.appspot.com/abbe3c7fc03eb43497686990488c54e2ae0533ea', 'sha1Sum': 'abbe3c7fc03eb43497686990488c54e2ae0533ea'}, 'index.html': {'sourceUrl': 'https://storage.googleapis.com/staging.ashah-146101.appspot.com/1865620cc55de1902c2a9636df601f532cb2657a', 'sha1Sum': '1865620cc55de1902c2a9636df601f532cb2657a'}, 'city.php': {'sourceUrl': 'https://storage.googleapis.com/staging.ashah-146101.appspot.com/64999cc8da06416a54be99c43e6e017aa0c1d01a', 'sha1Sum': '64999cc8da06416a54be99c43e6e017aa0c1d01a'}}]
Updating service [default]...
INFO: Previous default version [ashah-146101/default/20161113t122802] is an automatically scaled standard environment app, so not stopping it.
The index.html page loads fine, but when I try to enter names of cities (that I know are in the database), I see the following error in the Google Browser Inspect Element console.
Failed to load resource: https://ashah-146101.appspot.com/city.php?query=P the server responded with a status of 404 ()
Please help!

Firefox SDK: Redirect to ressource HTML denied

I'm trying to write a Firefox Addon with the Addon SDK to redirect some websites based on their URL. I have created a HTML page and put it in the data directory. I get the path with:
var data = require("sdk/self").data;
var myWebsite = data.url("myWebsite.html");
I'm using PageMod to start a script given an array of URLs:
pageMod.PageMod({
include: ArrayOfUrls,
contentScriptFile: "./myScript.js",
contentScriptOptions: {"myWebsite" : myWebsite}
});
In myScript.js I'm checking if some requirements are fulfilled and if so I try to redirect to my local website with:
window.location.replace(self.options.myWebsite);
But I always get the following error message in the console:
Object
- _errorType = Error
- message = Access to 'resource://myAddon/data/myWebsite.html' from script denied
If I enter the path to the local website (resource://myAddon/...) manually in the adress bar of the browser it works. If I redirect to another website (e.g. http://example.com/) it works as well.
So I guess there's a security setting or so I need to change to make the local redirect possible, but I can't find anything in the documentation or on the web. I hope somebody here can tell me what I'm doing wrong.
In package.json I had to add the following line to make it work:
"permissions": {"cross-domain-content": ["resource://myAddon/data/"]}
Further documentation can be read in link Noitidart provided in his comment.

Static website in Google Cloud - how to set mainpage (when index.html is in a different folder)

I just joined. I created a bucket for my static website. The index.html (or mainpage per google terminology) is in a different folder in the same bucket. I set my index.html as the page to show up automatically (www.example.com)
I get the website on my browser if i type exact http url including my file name - IT WORKS. But, if i type the domain name alone on the browser, i get the following error:
<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
</Error>
I did setup my MainPage on the bucket options. HEre is my gsutil web get.
{"mainPageSuffix": "gs://www.example.co/NewHome/index.html"}
But index.html does not show up when i type only example.co in the browser. Any suggestions???
Found the answer the path is relative to home (bucket).
So this works
{"mainPageSuffix": "NewHome/index.html"}.
In case the developers of the Google-cloud for web are listening to this...
Even though the system picks up the index.html in a different folder, the images, jss etc are not pickedup. The current working directly still remains the home directory. (In the web case this could be relaxed to change the CWD based on where the mainpage suffix is pointing to. (just an opinion).

dropbox - get an {"error": "Invalid origin"} when i try to upload a file

I was try to upload a file using the Drop box Saver as following:
"https://www.dropbox.com/developers/dropins/saver"
I see the Drop box saver button and when I'm clicking on it I get an error: {"error": "Invalid origin"} in a popup...
I also added to the "Drop-ins domains the local host ip,127.0.0.1
In the popup window that open when clicking on the button there is the uri:
https://www.dropbox.com/saver?origin=file%3A%2F%2F&app_key=undefined&version=2
Maybe the problem is that after the word "file" there are the following characters %3A%2F%2F and there is no file name or location...
app_key is undefine although i added it
What can i do?
It looks like you're opening your HTML directly from the file system instead of running a web server. I believe you'll need to actually run a web server (could be as simple as python -m SimpleHTTPServer) so the URL in the address bar starts with http (or https) and has a domain.