Chrome extension to sync files with USB drive - javascript

Is it possible for a chrome extension to sync files and directories between a USB drive and the main HDD?
This might be useful for example for easy downloading of photos from a digital camera.
To implement this feature, one will need two main parts:
read-write access to the local hard drive
read-write access to the USB drive
#1 is covered by the HTML5 filesystem APIs (see here for example).
#2 is the problematic part, as I don't know of any available mechanism that allows that.
It might be possible to somehow utilize the USB experimental api to implement a mass-storage device protocol.
However, my knowledge in USB protocols is too limited to know whether this is actually possible or what it may involve.
Thanks

One possible solution (though it's a Big Hammer) is to use a Native Host - basically, a separate program that has full OS APIs, and to which your extension talks.
Cons include the fact that the native host cannot be bundled with the extension in the Web Store, unlike NPAPI plugins (which are no longer an option).
chrome.usb and chrome.fileSystem APIs mentioned in another answer are not available for Chrome extensions, only apps.

Related

chrome.fileSystem only available in Chrome apps

I have an extension that uses chrome.webRequest, chrome.browserAction etc., but my extension also need to access the file system(unsandboxed), I found that chrome.fileSystem can do this, but it's only available in Chrome apps. Since I have to choose either extension or app, so this means that I can't use chrome.webRequest and chrome.fileSystem at the same time?
I wonder why Chrome extension doesn't allow the fileSystem API, I think it will be very useful.
Short answer: security reasons.
Extensions are considered much more risky than apps. Extensions can do a lot of things that apps can't, like hook into web request or inject script into pages, for example. Apps are kind of sealed via CSP and their run time model is much more isolated.
For this reason APIs which are considered risky - and fileSystem is probably the most risky API we have - are by default not made available in extensions.
Having said that there is ongoing discussion about how we can make more APIs available to extensions.

Random access (or at least incremental) write to file from a browser-hosted app

I am designing an application, which is intended to be run in a browser. This application is generating some data, which is then to be saved to a file. In certain cases amount of this data could exceed amount of available RAM, so we can't wait until all data is created and only then write it to disk at once.
I need a random access or (at least) an incremental (i.e., appending) write to file from a browser-based application.
In my research I've found following:
HTML5 FileSystem API: Gives us exactly what we want, but as for current moment is only available in webkit-based browsers (Chrome, Opera). As this document states, Firefox is not planning to implement it in nearest versions, no information about IE11 or Safari 7 is available.
All js-based implementations of file saving procedure I've found do not support this (expectedly).
Flash has a class FileStream but it is not available in an in-browser Flash player.
Silverlight also has a FileStream class but an application using it needs to be an elevated-trust application. Browser-based Silverlight applications can only be elevated-trust applications if it is stated so in the Windows registry. This is obviously not an option for a web application. Furthermore, this is probably not possible to do on Mac OS.
Other options that I see here are ActiveX and Java.
So, am I missing something with js, Flash or Silverlight? Is it possible to do with ActiveX or Java? Are there any other options?

Questions regarding AppJS / Tidesdk

So not sure if this would be the correct place to ask these but I know I could perhaps get some answers.
I am getting into Meteor and now would like to make some desktop apps. I was going to go the route of just making a native Mac app. But then I found the app wunderlist and its open source making use of the tidesdk.
Anyways I was hoping to get some feedback just in general about these frameworks (pros/cons etc). I don't really have a conceptual understanding of what they do. (or what the main difference between the two is).
I notice you can do routing in them. How is this working exactly? Because there is no URLs or client/server side.
Another thing I was wondering is if it would be possible to use MeteorJS on the desktop in a similar way?
Thanks.
Working with TideSDK is quite easy. We are working to make the experience great for developers. You are essentially just creating an HTML5 app in a special Resources folder. In most cases you can drop an HTML5 app directly into the Resources folder, point to the index.html using TideSDK's configuration and have it running in minutes. TideSDK can be used to run clients, servers, processes, and workers. I tend to work with frameworks such as backbone.js where routing is baked into a single page app.
At the core of TideSDK is WebKit, the core technology that powers the Safari and Chrome web browsers. We use three different ports of WebKit in TideSDK, one to reach each platform (Windows, Mac, Linux). On OSX, we can also use the native WebKit. The APIs of TideSDK provide native UI capabilities (that we are enhancing over time). These include native windows, system trays, menus, and dialogs. You can also interact with the clipboard. We have networking and database capabilities, system notifications, and more. We patch Webkit to allow the interpretation of python, php or ruby in the DOM in script tags and are able to bridge objects between languages. Our API's really allow your to reach the resources of your system including interacting with its filesystem.
It would be fun to run meteor in TideSDK. It is currently possible to run node.js within TideSDK using an appropriate startup process so I cannot see an issue running meteor so that it can run client and server within an app.
If you need your apps to reach Apple's AppStore, TideSDK is the only framework that I am aware of that has this potential. Competitive frameworks use ports of WebKit that are not native to the Mac such as the Chrome port (appjs) or the QT port (Sencha Ion). Apple's scan of an app based on these ports will reveal the use of "private APIs". Therefore, you would could not enter the AppStore marketplace with an app based on these. TideSDK is different and can use the native WebKit implementation on OSX. More about this capability will be revealed in the upcoming TideSDK-1.4.0 release. Our upgraded WebKit will also bring the HTML5 capabilities right up to date with the trunk of WebKit. Many of our users are waiting for this important update.
With WebKit eliminated as a barrier to the AppStore, the last issue facing a developer is Apple's sandboxing and entitlement to the resources of the system. We are looking at possible solutions to aid developers with sandboxing requirements. Some apps will be suitable for sandboxing and others will not. That said, if your goal is AppStore compliance, you will need to work with restrictions Apple has in place. I hope this helps.

How to change registry settings on a system through web browser

I am trying to develop a web page that will allow user to edit registry settings in windows system. Can i achieve it with client side scripting language.? If yes please suggest me language to do.
Can we do it with jQuery or any other type of library.
Due to obvious security concerns, this is only possible in Internet Explorer(!). This is not a jQuery library, but an activeX control; so it's quite unpleasant to use.
You have been warned, so here is the documentation :
http://technet.microsoft.com/en-us/library/ee156602.aspx
Fortunately is impossible to access the registry from a web app: the only way you have is through an ActiveX control but I would not go down this road.
have a look at the below
Access registry from a web aplication
Far from ideal but ...
If you serve up a ".hta" file (HTml Application) from your web server, Windows will run it as a program outside of IE and give it the privileges of the PC user. It will be in a separate window and there won't be any browser features (Back/Refresh/Address bar etc).
Even then, modern versions of Windows will prompt the user with security warnings if a HTA is launched from anywhere other than a local drive.
I know this thread is old, but I am not sure I like any answers for this problem. Instead of trying to access the Registry directly through Javascript, try writing a Java Applet and talk to the java applet using Javascript. Then in the JavaApplet you can write some JNI code to write a native dll to do what you need. It isn't a direct solution to your problem, but it will allow you to do what you need across multiple browsers. The downside is that you can't use it on browsers that do not support running a Java Applet, such as a mobile platform.
This method will also require you to sign your Java Applet. This is how you get around the security issues. The user will have to accept the applet the first time to give the security access.

Can you use the JavaScript engine in web browsers to process local files?

I have a number of users with multi-megabyte files that need to be processed before they can be uploaded. I am trying to find a way to do this without having to install any executable software on their machines.
If every machine shipped with, say, Python it would be easy. I could have a Python script do everything. The only scripting language I can think of that's on every machine is JavaScript. However I know there are security restrictions that prevent reading and writing local files from web browsers.
Is there any way to use this extremely pervasive scripting language for general purpose computing tasks?
EDIT: To clarify the requirements, this needs to be a cross platform, cross browser solution. I believe that HTA is an Internet Explorer only technology (or that the Firefox equivalent is broken).
Would Google Gears work here? Yes, users have to install something, but I think the experience is fairly frictionless. And once it's installed, no more worries.
The application that I maintain and develop for work is an HTML Application or HTA, linked with a SQL Server 2005 backend. This allows various security restrictions to be "avoided". All the client-side components in the application are done with javascript, including writing files to locally mapped network drives and loading data into screens/pages in an AJAXy way.
Perhaps HTA could be helpful for your situation.
For an example of javascript accessing a local file, you might try taking a look at the source of TiddlyWiki, specifically the saveFile, mozillaSaveFile, and ieSaveFile functions. Just click the download link, open the html file it sends you, and search for those functions.
Of course, tiddlywiki is supposed to be used as a local file, not served over the web, so the methods it uses may only work locally.. But it might be a start.
Why not use a flash uploader? http://swfupload.org/
Adobe Flex 4 lets you to open and process a file on a local machine:
http://livedocs.adobe.com/flex/3/langref/flash/net/FileReference.html#load()
It's not exactly JavaScript, but hope that helps.
I believe you can accomplish this using the HTML5 File API.
It is supported in Opera, IE, Safari, Firefox, and Chrome.
you can use fs module from nodeJS to manipulate with filesystem nowadays!

Categories