JavaScript Filewriter in FireFox - javascript

I need to allow users of my Web App to save files in their local file system after working on an editor implemented with javascript ( to work on a browser )
I heard about FileWriter API in HTML5, but not sure if it is supported in any of the Firefox versions, particularly FireFox 5.
Does anyone have any alternatives apart from Server side processing to allow users to save files into their local filesystem ( ofcourse with a permission from the user ) in FireFox. As I read Google Chrome supports FileWriter API though am not been able to make it work yet.

FileWriter is a Google working draft
Firefox team is working on implementing FileWriter also:
https://bugzilla.mozilla.org/show_bug.cgi?id=557540

No, Firefox does not support FileWriter, and the standardization of this API was abandoned (1, 2). http://www.w3.org/TR/file-writer-api/ now states:
Work on this document has been discontinued and it should not be referenced or used as a basis for implementation.
It seems that that API didn't even provide the feature you seem to be looking for:
The API doesn't give you access to the local file system, nor is the sandbox really a section of the file system. Instead, it is a virtualized file system that looks like a full-fledged file system to the web app. It does not necessarily have a relationship to the local file system outside the browser.
What this means is that a web app and a desktop app cannot share the same file at the same time. The API does not let your web app reach outside the browser to files that desktop apps can also work on.
You could use localStorage or IndexedDB to store the data client-side, albeit not in an arbitrary file the user can select via filepicker.
You could write an extension that provides the necessary API to content JS. As of 2015, it's unclear which technology you should use for that.
Downloadify (Adobe Flash initiating a download) is also often mentioned when discussing this. This thread mentions an alternative based on data: URIs.

Related

Interact with user's file system

I'm working on web application that deals with files of different kinds and stores it's metadata (e. g. if it is Microsoft Word file, then I try to parse it, if JPEG - EXIF, and so on).
General workflow: the user selects a file stored in a database, presses check out file, then default user editor / viewer (e. g. for PSD - Adobe Photoshop) will be opened on user's PC. When user finishes working on file, she presses check in and web application uploads file for further post-processing.
Right know this workflow implemented using Mozilla Firefox AddOn SDK (particularly sdk/io/file and OS.File methods): web application interacts with an extension for downloading / uploading file. So my application is tied to Firefox. But guys from Mozilla is working on WebExtensions API and I'm afraid in future they will deprecate AddOn SDK at all. Unfortunately, WebExtensions API doesn't provide functions for interacting with a file system.
So my question is: is there any other ways to interact with file system from web application? May be WebAssembly will provide such capabilities (bad luck, due lack of documentation, I can not find any sensible information about it)? Anyway I want to write application that will be compatible with major browsers, so I don't want to deal with extensions / addons anymore.

How to access USB device in chrome?

I need a web application which is used to copy the files from usb drive. I can write a java applet to copy the files from usb drive, but chrome will not support applet any more. Could you please suggest any alternative to this?
I need a web application not a chrome app.
Chrome 61+ has an implementation of the WebUSB API
This would not let you issue a command to the OS/File system to, for example:
copy file://some_file_location/myfile.txt to file://USB_DRIVE/some_folder/myfile.txt
Chrome would need to read the files and write to the device directly. In other words the browser would be copying the files by reading them (see below) and then writing to the USB device. This would probably be quite slow and unfeasible for large files.
Your options to read local files are:
To run chrome with the --allow-file-access-from-files flag. This is a security issue/risk, and users would need to visit your site/application with this already on.
Use the File and FileReader, or the non-standard FileSystem APIs along with a input type="file" or drag & drop
Neither of these may be applicable to your problem/solution.
I'd recommend using node.js , its cross platform and can access usb ports from web browser..
Usb Library: https://www.npmjs.com/package/usb
Proof : How to send data to USB device in node.js using libusb
Hope this helps

Chrome extension private API?

Hello I would like to use networkingPrivate api, which one is from chrome private API, I have added permission for networkingPrivate but it seems that is not enough. Also I found this
These are only usable by extensions bundled with Chrome, they are not publicly accessible.
here: https://developer.chrome.com/extensions/private_apis, but I'm not sure what that exactly mean, and how to do that.
My original intention is to get info about wifi (ssid,...)?
Thanks
It would be a security risk to allow user extensions to access this information direct from the OS. I think the private API is for Chrome OS, so that you can access and modify OS features direct from the browser, since Chrome OS is basically just a browser.
You could try looking at Native Messaging, which I believe will allow you to connect your extension to a native application installed on the host's machine. The application written by you would have some link between the extension, and then you can pass messages between the two. For example, your extension could request network information, and the native app will get that and send this information back to the extension.
I haven't looked into this so I may be wrong, but worth investigating. I'd be very interested to see the result.
Private APIs are made for internally usage.
For example, DeveloperPrivate API is used on chrome://extensions page.
They have stronger power than other APIs. but they also have security issues if they are open. if you really need to use them, just ask to make new API.

Web mobile application with offline mode

To begin, I'm sorry for my awful english :)
I have a web application that will communicate frequently with a server running a
webservice offering JSON / XML. The application will send contact details / bills / products, and will have to manage an offline mode.
I thought to use this DOM cache (HTML5). However I must have constantly an updated customer list, bills etc. in offline mode because I can not make a request to the server.
It is therefore necessary to have an xml file on the mobile ... which will be read and modified. Is it possible and not too difficult to manage XML plaintext database with ExtJS (or another framework) on a mobile? (Android)
Thanks.
It's far easier to do with HTML5 storage, which you can use directly without the need for Sencha Touch API calls (providing you're on a supported device, iOS Safari supports web storage).
Have a read of this article from the Sencha blog.
Have a look at Lawnchair - this can be included in your app without a framework.
If you decide to use Sencha Touch you can use localStorage, which allows you to store key/value pairs in the HTML5 Web Storage on the device.
See this tutorial on the Sencha website. You could use localStorage to cache your json feed whilst making static assets available offline with a cache manifest file.

Reading / Writing files in Javascript - IE6

I need a database storage system for Javascript where the state can be maintained on the local disk.
Here comes the spanners in the works :-
It only needs to support Internet Explorer but the minimum version must be IE6
Files need to be written so they can be read in again later (upon closing and re-opening of browser)
There can be no web server (unless it's extremely easy to distribute and does not require a install) since the HTML pages will be distributed on USB.
Does anyone know of any solutions that might help here?
Have fun playing with userData. Apparently it does what you want in IE6/7
Then localStorage for IE8/9
Or you can use the heavier store.js which does the feature detection for you and apparently works in IE6+.
It should work in IE9 but no garantuees. I would recommend store.js as it's easier for maintenance and just works out of the box. You can also support other browsers that way.
I don't know if it's supported in IE6, but JScript appears to have some level of support for this through FileSystemObject.
var fso = new ActiveXObject("Scripting.FileSystemObject");
var a = fso.CreateTextFile("c:\\testfile.txt", true);
a.WriteLine("This is a test.");
a.Close();
According to Write binary data with FileSystemObject write(), ADODB.Stream appears to be an alternative.
For strictly local IE work use HTA Applications. Then you can access local resources (text files, ADO databases) without security problems.
try to read this post: Read/write to file using jQuery
Hope this helps.
I would suggest that you not try to read/write using JavaScript but instead head down the road of embedding a small web server on the USB drive. I did this for an app once and it worked out well. I used the Cassini web server.
I created two projects in visual studio. First, I created an ASP.Net web site to read/write from an SQLite database. This site displayed all my content and was built just like any other ASP.Net site. Second, I created a Windows Forms application that hosted the Cassini web server and presented the user with a form that contained a single web browser control. This made the user experience very simple ... they just clicked MYAPP.EXE from the root of the USB drive and the form opens, starts the web server, and navigates the browser control to the start page of the web site.

Categories