How to load local resource in Chrome App - google-chrome

In my Chrome App,I want to load local resources such as audio from user's disk.
If I add the absolute path in my code, the Chrome says "not allowed to load local resource"...
So,how to achive it? Thx
Please this is app not extension.

Chrome Apps are not allowed to access the user's file system directly. file:// URLs are forbidden, as are all the other ways you might try for accessing a file like /home/user/music/demo.mp3. This is by design (so users can install a random Chrome App and trust that it isn't going to read or write their files).
However, Chrome Apps have several APIs available for accessing sandboxed file systems. Since your example is an MP3 file in /home/user/music, you probably should use chrome.mediaGalleries, which will prompt the user for access to common media directories (like /home/user/music) at install time. Then you will be able to access certain file types in certain directories, and prompt the user for music and images in other directories.
As sowbug suggested, you could also use chrome.fileSystem, where you can prompt the user to open a file or directory of their choosing. This will give you access to all files in those directories, but you should only use this if you want non-media file types.

Related

Mediawiki: Links to open local files on the server doesn't work

I have MediaWiki installed on a synology server. I would like to create a link on the wiki that would allow opening of files on the same server.
Here are the steps I did to achieve this:
Added $wgUrlProtocols[] = "file://"; in LocalSettings.php
A test file on the server: file://myServerName/path/to/file/test.txt. Putting this URL in my chrome browser directly opens the file.
Create a page in MediaWiki with a link to this file using [[file://myServerName/path/to/file/test.txt]]
When I click on the generated wiki page, nothing happens. However when I hover on top of the link, it shows the correct URL.
Can someone please point out what additional steps I need to do to get this working?
The file:// protocol points to the file on your computer. I'm not fully sure, but I think you cannot use it to retrieve file from a different machine (read my comment below about samba shares).
From quick research it looks like Chrome browser blocks requests with file:// protocol, But browsers like IE should allow you to open those files. It is done because of security reasons so the malicious site cannot open local files without your permission. You might bypass that by installing a special plugin in Chrome (look for Enable file links)
Instead of using file protocol, make those files available via Synology WebStation, and then create links that point to the file via webstation (not via path on the server). With that approach, links attached on your MediaWiki pages will work as those will be regular links.
If you don't use the WebStation, you might also try with ftp:// links (use the FTP service), or link to samba shares - that's where the file:// protocol might work, but again - I'm not sure and I cannot test it as I do not use windows.
I think that the safest/easiest/fastest way is to expose those files via WebStation.
Source: https://en.wikipedia.org/wiki/File_URI_scheme
The file URI scheme is a URI scheme defined in RFC 8089, typically used to retrieve files from within one's own computer.

How to download or list all files on a website directory

I have a pdf link like www.xxx.org/content/a.pdf, and I know that there are many pdf files in www.xxx.org/content/ directory but I don't have the filename list. And When I access www.xxx.org/content/ using browser, it will redirect to www.xxx.org/home.html.
I tried to use wget like "wget -c -r -np -nd --accept=pdf -U NoSuchBrowser/1.0 www.xxx.org/content", but it returns nothing.
So does any know how to download or list all the files in www.xxx.org/content/ directory?
If the site www.xxx.org blocks the listing of files in HTACCESS, you can't do it.
Try to use File Transfer Protocol with FTP path you can download and access all the files from the server. Get the absolute path of of the same URL "www.xxx.org/content/" and create a small utility of ftp server and get the work done.
WARNING: This may be illegal without permission from the website owner. Get permission from the web site first before using a tool like this on a web site. This can create a Denial of Service (DoS) on a web site if not properly configured (or if not able to handle your requests). It can also cost the web site owner money if they have to pay for bandwidth.
You can use tools like dirb or dirbuster to search a web site for folders/files using a wordlist. You can get a wordlist file by searching for a "dictionary file" online.
http://dirb.sourceforge.net/
https://sectools.org/tool/dirbuster/

Chrome Extension edit source file

I have a chrome extension that is installed via "Load unpacked extension," and I am trying to get it to delete itself or at least change its source code when a function is called. I have the chrome.management.uninstallSelf down, but I also need the source files for it to become changed/gone. Basically, I need the chrome extension to open the local file where its source is located and then delete/change some of the files inside it. Is there any way to do this?
Basically, I need the chrome extension to open the local file where its source is located and then delete/change some of the files inside it. Is there any way to do this?
No, this isn't normally* possible.
Chrome extensions have only read-only access to their own files (via chrome.runtime.getPackageDirectoryEntry or requests to chrome-extension://), and no access at all to the rest of the filesystem.
* All bets are off if you have a Native Host module though. It can do whatever, but would greatly complicate installation.

How to allow-file-access-from-files in Chrome?

I am using Chrome to test some of my WebGL texture programs. According to the book 'WebGL Programming Guide', if I need to access files from my local disk, I should add the option --allow-file-access-from-files to Chrome.
How do I do that?
The short answer is DON'T
Open up a shell/terminal/command line and type
cd path/to/htmlfiles
python -m SimpleHTTPServer
Then in your browser to go
http://localhost:8000
If you find it's too slow consider this solution
The reason you don't want to allow file access is allowing it can be used to steal data from your machine. For example, you go to a site and download some webpage. You then view that page locally. With file access on that locally run page can now access all your files AND upload them to a server.

open shared folder from web application

I have one in house Perl web application (Windows OS), and I need to find the best way to open shared folder from my application with user default file explorer. I prefer some Perl module or some cross browser method (I don't know what browser would be used by user).
I tried with file:/// but I am searching for something better.
If what you are trying to achieve is something like accessing a file on a samba share, I would suggest simply using UNC paths (\yourserver\shared_folder\filename). If you point to an actual file it will be opened by the default program associated with that extension in Windows. If you point to a folder, the windows explorer would open up in that folder, as if you typed the UNC path in a start -> run dialog box.
So in perl this would be like below, if your shared folder is on server named "phobos" with a share "movies".
system('\\phobos\movies'); # mind the quoting!!
If you were trying to open up a file in the default program in windows you would use something like:
system('\\phobos\movies\my_cool_movie.avi'); # mind the quoting!!
Is that what you mean with your question?