This workflow works fine for me: 1. put blob data to local store 2. set, for example, img.src = our temporary url 3. destroy data in local store after small timeout (<1s)
It seems that destroying is deferred until data is read from local store. So I suppose it's safe to destroy it after it is known that reading begins. On 12 окт, 07:04, MG <[email protected]> wrote: > Hello! > > Is there a way to create temporary/transient stores that are > automatically destroyed/cleaned up once the user closes the current > window/session? > > My use case: > > Let's say I am writing a browser-based image manipulation application > (it's something else, but it is easier to explain this way). For > performance reasons, as well as the ability to work offline, I am > using Gears to do everything on the client side. > > So the scenario: > > 1. open an image (desktop.openFiles()) as a blob, read it into bytes[] > (blob.getBytes()) > 2. do something with it, let's say crop/rotate (javascript working > with bytes[]) > 3. save it locally by creating a resource store, building a blob from > bytes[], capturing the blob as a fake URL, then doing window.open with > that URL. > > Everything works more or less well (let's ignore for now performance > issues). > > The problem I have is that I see no way to determine when I should > remove the URL from the store, and/or the store itself. If I did it > with a server round-trip I could use various techniques to determine > that the file is no longer needed (from just cleaning up everything at > the end of the request/response to counting the number of downloads), > but I have no idea how to determine if the user has already > "downloaded" the file. > > This is a major security/privacy issue for us: leaving user data in > gears' cache forever is 100% out of question - we have to clean up > everything by default. > > So is there a way to create a temporary store/URL? Or a one-off URL, > that automatically self-destructs once fully read? Or maybe there is a > higher-level (non-gears related) JavaScript trick to determine when > window.open actually finishes everything, maybe by monitoring the > result of window.open? > > Thanks, > MG
