Does anybody know how to read google gears blob objects within the browser? I'm using gwt on top of gears, but I'm looking for any kind of solutions. The application needs to work fully offline so I can't post the files and process them server side. My files are simple text files that I want to upload and parse in offline mode.
I wrote a very simple class to do this you can check it out here: http://procbits.com/2009/07/29/read-file-contents-blobs-in-gwt-and-gears/
It's very simple to use. Either call the method "readAllText" or you can read it line by line. Here is an example reading line by line:
try {
Desktop dt = Factory.getInstance().createDesktop();
dt.openFiles(new OpenFilesHandler(){
public void onOpenFiles(OpenFilesEvent event) {
File[] files = event.getFiles();
File file = files[0];
Blob data = file.getBlob();
BlobReader br = new BlobReader(data);
while (!br.endOfBlob())
Window.alert(br.readLine());
}
}, true);
} catch (Exception ex){
Window.alert(ex.toString());
}
I hope this helps!