Live data from Hacker News

Reading local files in JavaScript (HTML5)

html5rocks.com

21–26 of 26 posts

Re: Reading local files in JavaScript (HTML5)

#21
I have used this for a few things. One of them that was the most interesting to code, even though very narrowly useful, was a way to compare two memory dumps from a C++ game to find the objects that don't match (after the game detects a checksum mismatch between online players, the players are asked to make these dumps, and then submit them to us; We drag'n'drop two dumps into a webpage and get a printout of objects that don't match). Admittedly a C++ app would have been a lot faster, but Chrome still managed to read the dumps and extract the relevant info in several seconds.

Re: Reading local files in JavaScript (HTML5)

#22

Earlier quoted context omitted.

When you say cross-domain AJAX, do you mean JSONP or proxying, or is there another technique I'm not aware of?

https://developer.mozilla.org/en/http_access_control

Apologies for veering off topic a bit...

Does have experience with the CORS "partial support" in IE?

[http://en.wikipedia.org/wiki/Cross-Origin_Resource_Sharing]

Re: Reading local files in JavaScript (HTML5)

#23
post #10

Earlier quoted context omitted.

well you can always use file system api. http://www.html5rocks.com/en/tutorials/file/filesystem/ but its chrome only

For what it's worth, TiddlyWiki can save itself on the filesystem even with Firefox (user gets prompted to allow access). I don't know how it works though and when I tried it seemed to be quite buggy.

According to Wikipedia they use FileI/O, a Mozilla API for accessing the filesystem, which from what I can tell it's more directed at Addons than webpages.

Re: Reading local files in JavaScript (HTML5)

#24
post #19
post #10

Earlier quoted context omitted.

well you can always use file system api. http://www.html5rocks.com/en/tutorials/file/filesystem/ but its chrome only

What about security? I assume its not possible to read and write arbitrary files in the fs?

From parent's link:

If you're calling requestFileSystem() for the first time, new storage is created for your app. It's important to remember that this file system is sandboxed, meaning one web app cannot access another app's files. This also means you cannot read/write files to an arbitrary folder on the user's hard drive (for example My Pictures, My Documents, etc.).

Re: Reading local files in JavaScript (HTML5)

#25
post #19

Earlier quoted context omitted.

What about security? I assume its not possible to read and write arbitrary files in the fs?

From parent's link: If you're calling requestFileSystem() for the first time, new storage is created for your app. It's important to remember that this file system is sandboxed, meaning one web app cannot access another app's files. This also means you cannot read/write files to an arbitrary folder on the user's hard drive (for example My Pictures, My Documents, etc.).

Thank you for pointing it out. I assumed it would be like this but didn't find it scanning the page.

Re: Reading local files in JavaScript (HTML5)

#26
post #20
post #11

The spec changes quiet often and if you do the javascript file stuff alot (my startup deals with local files with javascript so i use js for files alot) you will come across something that has been changed from what it is on html5rocks. It gets ugly very quickly. When i started it, the condition was alot worse, there was practically no one writing any tutorials. Your only option was to reverse engineer the spec draft…

I've found the same thing. I'm holding off on implementing some of this stuff (outside of prototypes) because it seems Safari/IE support is missing and there isn't a decent polyfill that I'm aware of.

hmm there is not much to hold ground on any browser other than chrome. Filesystem api wasn't stable the last i checked in FF. Any public implementation that runs on atleast 4 major browser is still atleast 6 month away :( My app is in chrome webstore so i don't have to worry about browser support and chrome also updates automatically so if it works in latest stable, i can launch without thinking twice :)
Post reply on HN