Hi MG,

You can't believe how helpful your question has been for me. Until now
I was under the impression that Gears could not server client-created
files locally and this was a pretty big problem for me.

I'm not a skilled coder but I played around a bit in a thesis
prototype I am working on. Your problem also occurs in Safari on OS X.
I did not find a satisfactory solution that doesn't require changing
browser settings (to prevent IE &Safari from opening text files).
However, I found two workarounds. The first meets my requirements
reasonably.

1. Make the file available as a link and explain users to right-click
and select 'Save Target As ...'. This might be slightly better than
opening a new window and requiring users to save the opened file.

2. If IE is your only concern you could detect the IE user agent and
use an alternative local file save solution that ONLY works on IE I
believe, such as explained here:
http://4umi.com/web/javascript/filewrite.php?txt=This+is+where+the+text+goes.%0D%0ANew+lines+go+here.&filename=C%3A\My+Documents\filename&ext=utf-8#.

If anybody knows a better solution please post it here!

Cheers,
Martijn


On Oct 24, 6:32 pm, MG <[email protected]> wrote:
> Hello!
>
> I am using the following code to save a text file to a local computer:
>
>                 var srv = google.gears.factory.create('beta.localserver');
>                 var store = srv.createStore('mystore');
>                 var sResourceName = 'file.export';
>
>                 sResourceName = escape(sResourceName);
>
>                 if( store.isCaptured(sResourceName))
>                         store.remove(sResourceName);
>
>                 store.captureBlob(blob, sResourceName, 
> 'application/octet-stream');
>
>                 window.open(sResourceName, '_blank');
>                                 setTimeout(function(){
>                                         store.remove(sResourceName);
>                                         callback(true);
>                                 }, 1000);
>
> FF & Chrome properly open the save file/download window, but IE8 opens
> the blob as text in a new browser window. Is there a way to force IE
> to save the file instead of showing it in a window?
>
> Thanks,
> MG

Reply via email to