How chrome extension download images to extension root directory - google-chrome-extension

I'm making a chrome extension for the first time.
For my extension, I want it can automatically download images to its extension folder. For example, if the extension folder is /xxxx/abc/, I want it can download images to /xxxx/abc/image/.
To make it, I don't know how to write file/ download image to this directory. I don't want users notice this.
I found an extension can make it. It's called Momentum. It can download images to /xxxx/<extension root dir>/backgrounds/.
Can anybody tell me what technique do I need? Thanks a lot!

No, you can't. An extension has only read-only access to own files.
Instead, you can download to a virtual HTML5 filesystem and use files from it. See this tutorial - the big red warning means no other browser uses this technology, but Chrome does.
You may want to declare "unlimitedStorage" permission to make sure you have the space to store the files.
This being a virtual filesystem, those won't actually be files you can open on your disk. If you need to give files to the user afterward, you can use chrome.downloads to write them to the downloads folder, but that's "write-only", you can't access the contents afterwards.

Related

Need help in developing a custom WebDav client using node.js

I am developing an open source application which should mount webdav share to local drive letter just like NETDRIVE and WEBDRIVE using node.js and electron-js, so in my application at present I am downloading all files from webdav share which takes a lot of time and not reliable for heavy data. Is there any other approach so that whenever user access a file, only that particular file should be fetched from webdav share, I’ve tried to display files meta data(dummy) structure in directory and kept that directory under file-watcher. So that when user tries to open a file then watcher should capture file open event to get which file was user trying to access, so that in background of application a service will triggered to fetch that particular file using file-path as reference, but none of them are unable to capture file open event. Is there any other approach to do so, correct me if I am in wrong direction.
Thank's
I think you want virtual file-system and recommend Dokan library.
Dokan is the start point of Windows virtual file-system application.
Open Source : Dokan (https://en.wikipedia.org/wiki/Dokan_Library)
Commercial: EldoS CBFS (https://www.eldos.com/cbfs)
Google, Naver use Dokan and NetDrive, RaiDrive(mine) use CBFS.

Possible to set local folder for automatic file uploads

Bit of a loose question so if it gets marked down I'll remove it.. but..
I'm using Primefaces/Spring/Hibernate for Java server.
My application knows a load of file names I need to upload. Those files are on my local computer. Is it possible to tell the application the root directory of these files, for it to then setup uploads for each of these files without me needing to browse for each file individually?
I assume this is a browser security issue, i.e. the user needs to explicitly state which file the application is allowed to know about etc?
If not I'll have to do it in a local application but I was hoping there was a way a mass upload could be kicked off from the browser by just setting the local directory of the files.
I decided to use the Primefaces uploader, upload all the files in the directory and let the application sort them out once it has them on the server.

uploading new files to vhost. Need to change the privacy settings. Linux

My website has a feature that uploads files and displays them. So there is a folder in the public directory that stores those files.
But the main problem is that after each upload, I have to manually change the privacy of that particular file, otherwise it gives me error 403 Forbidden.
Can anyone please tell me how to make it world readable automatically, without me manually updating it each time?
This is Linux - Fedora
p.s. Just a beginner
Using php command - chmod($target_path, 0644);
http://php.net/manual/en/function.chmod.php

Is there a way to use a downloaded (xml-esque) file in an extension?

I'm attempting to write an emusic download manager extension for Chrome. This would essentially involve parsing the .emx file (xml-esque) downloaded from the site to get the temporary music file URL.
I've gone through everything I can find online about extensions working with downloads, but the problem comes in that the .emx file isn't directly accessible from the web. The link to download it seems to pass through a counter for your account so that it can deduct the cost, and then it pushes a file 0.emx to be downloaded. It doesn't seem to work with any hotlinking, even copying and pasting the button's destination URL into the same browser tab.
I think the only way to get the file is to wait for the 0.emx file to be pushed. Is there any way I can use an extension to intercept that file before it goes to the downloads folder or use it after it's already downloaded?
Thanks!

How can I open a local file with a local program through my browser?

On my webpage, I have placed a link to a local file (e.g. "text.docx" on my local HD). I would like to double click on this link, and have a third party software which is installed locally on my PC (e.g. Microsoft Word) open it.
I would like to be able to do this with Firefox and Google Chrome. Obviously, I am a newbie to web programming.. can somebody show me the way? I have looked around and had the impression that I need to write and add an extension, maybe?
Thanks for your time. Jakob
This is only possible if you know either the absolute path to the file or the relative path from whatever working directory your browser runs from. You the create a link with
href="file://relative/path/to/file/text.docx"
or
href="file:///absolute/path/to/file/text.docx"
and any modern browser will query the system database for the mimetype of the file depending on its extension, thus prompting to open the correct application.
EDIT
I inawarently introduced a unixism in the previous code: Distinction bewteen absolute and realtive paths as above works well on current *nix desktops, but in Windows an absolute path will most likely look like
href="file://C:/drive/absolute/path/to/test.docx"
Mind the 2 (not 3) slashes a the beginning, and the forward (not backward) slashes.
As far as I know, you can't link to local files from a website. If you upload it to where your files are, you could then be able to download it.
I was able to execute code locally, using Firefox, by adding an extension which used the XPCOM interface. One such extension was "commandrun", and may be found here: https://github.com/aabeling/commandrun .

Resources