Fork me on GitHub

7 Sept 2009

Session Bound Temporary Files

I've just released Session Temp Files, a very simple plugin for managing a temporary file storage space bound to the HTTP session. I'm working on something where a user uploads a file at the start of a webflow conversation, the flow then validates the file and may require the user to enter extra information before finally the file is saved and an associated record is added to the database. The uploaded files needed to be stored somewhere between the initial upload phase and the successful outcome of the flow where they will be copied in to a permanent storage space. The file is really too big to keep in memory in the flow scope. It's easy enough to create a temp file and delete it at the end of the flow (even if the user cancels out of the flow) however users can also do things like close the browser, suddenly decide to do something different and type in a new URL, etc. The webflow then gets abandoned in an intermediate state. The flow itself will be destroyed when the HTTP session ends but the temp files I created will hang around until the OS decides to sweep the temp directory.

The plugin simply allows you to create a directory within the normal temp directory - System.properties."java.io.tmpdir" - that will get deleted when the HTTP session expires. It binds two new methods on to HTTPSession: getTempDir() returns the session's temp directory, creating it if it doesn't exist and createTempFile(prefix,suffix) works like File.createTempFile except that the file is created inside the directory returned by getTempDir.

The code is up on GitHub and the plugin is available from the standard Grails plugin repository via grails install-plugin session-temp-files.

7 comments:

Williamchen said...

I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenter’s here! It’s forever nice when you can not only be knowledgeable, but also entertained!That is the outstanding mindset, however is just not help to make every since whatsoever preaching about that matter. Almost any technique many thanks in addition to I had try to promote your own article in to delicious nevertheless it is it seems that a dilemma using your in order sites can you please recheck the idea.
Visit : Best essay writing service

lilyjohnson said...

Hi guys! There are many essay writing service providers available but writing a quality essay at an affordable rate is really hard to find. I think this https://exclusive-paper.com/essays/analysis/profanity-how-harmful-is-it.php help to prepare a quality essay at an affordable rate. Thanks for the information shared.

Andrew Lewis said...

Hey! I agree that there should really be a way to retain the temp files that get deleted for some reason. If you have introduced an idea which you think is effective so I hope it gets approved as soon as possible. As a student, I keep on switching web pages on and off. Sometimes while searching for a research paper and sometimes while looking for someone to make my assignment for me.

1292lillyS said...

Thanks for sharing this with everyone. You have no idea how long I've been looking for something like this Session Temp Files. It's so incredible that I find you so unexpected. I was looking for letter writing service online for my study because I have no idea how to write my work.

billygiil said...

Truly, this article is really one of the very best in the history of articles. I am a antique ’Article’ collector and I sometimes read some new articles Buy Gadgets online if I find them interesting. And I found this one pretty fascinating and it should go into my collection. Very good work!

Harry Oliver Krock said...

I appreciate what you have shared with us. I have already visited several blogs and they always provided me with something interesting. I would like to visit your other blogs but right now I have to find someone whom I can Pay To Do My Assignment on an urgent basis. I assure you I will visit your blogs again right after my assignment.

James Wilson said...

I really appreciate what you have shared with us. I have already visited several blogs and they didn't provided me info like yours. I would to read more articles of yours but right now I looking for someone whom I can Pay To Do My Assignment on an urgent basis.