# Handling temporary generated image/graphs

**URL:** <https://www.ruby-forum.com/t/handling-temporary-generated-image-graphs/181070>\
**Category:** Rails\
**Created:** [January 5, 2010, 1:14am UTC](https://www.ruby-forum.com/t/handling-temporary-generated-image-graphs/181070 "2010-01-05T01:14:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jriisbovbjerg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a5b964/32.png) [@jriisbovbjerg](https://www.ruby-forum.com/u/jriisbovbjerg)\
**Post date:** [January 5, 2010, 1:14am UTC](https://www.ruby-forum.com/t/handling-temporary-generated-image-graphs/181070/1 "2010-01-05T01:14:55Z")

</div>

Hi,

I have an application where I based on users selections generate a  
dataset for them to download and a graph describing this data. The  
graph is made with gnuplot and work really well - no problems 🙂

But I save the graph to a file say “graph.png” in the public/images  
dir and use it in the view. I have a strong felling that when more  
than one user is generating graphs I will have a problem, since  
they’ll keep overwriting the same graph again and again.

I realize that I could add some sort of session id or time stamp to  
the image, but I don’t want to fill my server with abandoned images  
and the users are not likely to request the same image/graph again any  
time soon.

Is there any concept like a temp store where all files more than 5  
mins (or 1 day, don’t matter 🙂 old are deleted, or a round robin  
scheme where abandoned filenames get recyled.

Have I missed some vital function, - or is it just a matter of a cron  
job to clean up after a hard days job?

regards  
Jan

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![jriisbovbjerg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a5b964/32.png) [@jriisbovbjerg](https://www.ruby-forum.com/u/jriisbovbjerg)\
**Post date:** [January 5, 2010, 1:25am UTC](https://www.ruby-forum.com/t/handling-temporary-generated-image-graphs/181070/2 "2010-01-05T01:25:28Z")

</div>

> job to clean up after a hard days job?  
> Probably easiest to have cron do it. Make sure the filenames are  
> unique – combo of user’s login and a timestamp say, then have your  
> cron job use ‘find’ to find old files and delete them. Run it every  
> hour or whenever necessary.

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).
