I have downloaded a image file using third party api and written in window persistent storage
name called pogo.png how can I retrieve and execute.
For debugging the Filesystem API, you have a few options:
1.Use this this extension to view/remove files.
2.See the tips here: tips That includes viewing stored files very easily using the filesystem: URLs.
3.Drop the Filesystem Playground demo (http://html5-demos.appspot.com/static/filesystem/filer.js/demos/index.html) into your origin. You can use that to view/rename/delete files/folders easily.
4.Chrome DevTools now has support for the Filesystem API in Chrome Canary...at least viewing the files stored under an origin. To use that, right now you need to enable Developer Tools experiments in about:flags, restart, hit the gear in the devtools (lower right corner), and enable the 'FileSystem inspection' under the experimental tab.
Related
This is an odd use-case and I've tried to steer the users away from this, but I have a request to load locally stored PPT files in an HTML environment.
The idea is to view the PPT in an iframe so that I can "decorate" all around it. Users will be creating playlists, of sorts, so I need to add "next" and "previous" presnetation buttons, etc.
I have an online version of this working using the Office webapp link that many other posts have shared, but there is a concern for poor connectivity so they want it to be available offline.
My instinct was to shape this up as a PWA. I can make them use Chrome, so I have the FileSystem API "caching" the PPT files from the online source. However, I have no way to render the saved files!
Because it's offline, I can't use googledocs or continue to MS web office.
I don't know the AppCache feature well enough, but wondered if I can preload all of the docs in an iframe, will it cache those. My thought is that it won't, because the content is on microsoft (or Google's) site.
All users will have a legal copy of PPT on the computer, if that helps at all.
So far I have tried storing the files using the filesystem API in combination with the Chrome offline viewer extension and alternatively the Native Docs extension. The Chrome one will allow me to open a doc, but directly in edit mode. I need to simulate the behavior of a ppsx file, but neither extension works with ppsx files and I don't see documentation for an API that will allow me to "auto-play" the presentations.
Thanks for any ideas!
Wayne
I'm writing a chrome extension which will add custom images to a webpage. I want the users to put all their images in the "backgrounds" folder, and I want my extension to be able to retrieve the file names of every file in the "backgrounds" directory in the extensions folder. It seems like there is no way to do this in chrome extensions. When I try to use the chrome fileSystem API, I get this error:
There were warnings when trying to install this extension:
'fileSystem' is only allowed for packaged apps, but this is a extension.
How can I do this?
You can get read-only access to your extension's folder with chrome.runtime.getPackageDirectoryEntry, with which you can work using the HTML5 FileSystem API.
However, this will not allow you to do what you want to do.
While you're developing an extension, it will work fine, as Chrome does not mind changes to the extension's folder - they are expected.
However, when the extension is deployed to users, Chrome will maintain a cryptographic hash of the extension folder's contents. In case there are any external modification to the files, the extension is considered compromised and is forcibly disabled.
So you should consider other approaches instead, such as:
using the above HTML5 FileSystem API to have a virtual persistent filesystem to which you can let the user "upload" files through your UI;
storing data as blob:/data: URIs in chrome.storage or IndexedDB;
asking the user to put the files in a cloud drive your extension can access using its usual API.
I am new to building Chrome extensions. I want it to be able to allow the user to choose a local folder and one random picture from there should be displayed for every new tab.
As of now, I have the images in the extension folder and have hardcoded the image names for access.
I read the following SO questions around this:
Open (Import) file in a chrome extension
Access Local Files using a Google Chrome Extension
But I am not sure which one to implement and if they are the way to go.
It's not possible* with an extension to maintain a persistent access to a folder in a filesystem. Chrome Apps can do it, extensions cannot.
Your best bet is to allow upload of files into a virtual filesystem. But it will not allow modifying the pictures without interacting with your extension again.
Alternatively, you could integrate with some cloud provider, i.e. monitor a folder in Dropbox.
* P.S. Regarding NPAPI, yes, it's being deprecated, but there is an alternative: you can have a Native Host program that your extension talks to. However, it makes it very awkward to distribute the extension - Native Host can't be submitted to Chrome Web Store. But in principle that can give you the full power of a native app.
I'm making an extension that among other things edit a javascript file in an external editor (one on the user's computer). The extension has the javascript file saved in chrome.storage but it will ofcourse be a lot easier for the user to write code in their own editor.
This is why I decided to find something that creates a file on the user's filesystem which the user can find and edit it themselves, and if any changes are made, sync that back up to the extension (either by periodically checking or by using some listener).
I have looked around but nothing really seems to fit what I'm trying to do. Chrome's fileSystem API only works for chrome apps, not chrome extensions and the HTML5 fileSystem API does not allow for a simple filesystem URL to be requested and opened, instead it obfuscates the stored file and makes it practically impossible to edit that file easily.
Something else I looked at which might be more promising is letting the user edit one of the files in the directory where the extension is stored and somehow retrieving that content. This is however going to be a bit tough to implement with chrome's all the hash checking going on in chrome extensions not to mention the general modifying of those files' contents by the extension (possibly by hacking around by specifying your own update URL and "updating" a dummy javascript file that is going to be written to).
Is there any way to simply ask for a location to store a file and then allow the user to edit that file and sync it back up?
No, extensions are sandboxed from the real filesystem.
As you said, it's possible to read extension's own files; however, this is read-only for the extension and modifying those files on a deployed extension will result in Chrome detecting extension "tampering" and immediate disabling as a precaution.
The only way for a Chrome extension to escape the sandbox is, as wOxxOm suggested, a Native Host module. Note that this cannot be distributed in Chrome Web Store with the extension; it needs a separate installer.
Alternatively, you could use some sort of cloud storage with API to access it; e.g. a user could store something in a Dropbox subfolder, and your extension can authorize access to it via Dropbox API. Unfortunately, there is no "native" solution like syncFileSystem for Apps.
I want to create an extension which copys from a folder from a path to another path using javascript in a google chrome extension (else I can't access the user system I think)
I've already found this out that I have to add "file://*" in the manifest in order to access those files and of course there is the File API in HTML5.
But how can I copy the files? From html5rocks I know how to read them, but I couldn't find out how to copy them.
Unfortunately, you cannot access an arbitrary location on the user's filesystem (for writing).
Both, the related HTML5 APIs and the chrome.fileSystem API do not allow to modify or save files to arbitrary location on the user's filesystem. Your app/extension will be allowed to operate within a confined, sandboxed environment (virtual filesystem).
There are a few related answers here, in StackOverflow, e.g.:
here, here and here
More info on the APIs:
File API Specification
Introduction to the FileSystem API
chrome.fileSystem API