Hello guys, I am having the option to download certain folders on my app in zip format. So every time a user requests one I''m doing a system call to zip the folder (ex: system(''cd ''+path+'' && zip ...) and then the send_file method to send it. What happens is that I''m keeping track of disk space so I need to delete the zip immediately. I was wondering if there is a way of creating the zip file in a sort of tmp directory and send it via send_file from the tmp path. I don''t know when the file transfer is over to delete the zip file and having a cron job to delete zip files is not an option (disk space could be surpassed by the zip file and the user will have to wait for it to be deleted to be able to create new files). Can anyone point me in the right direction please. Thanks, Elías --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Elias Orozco wrote:> Hello guys, > > I am having the option to download certain folders on my app in zip > format. So every time a user requests one I''m doing a system call to > zip the folder (ex: system(''cd ''+path+'' && zip ...) and then the > send_file method to send it. > > What happens is that I''m keeping track of disk space so I need to > delete the zip immediately. I was wondering if there is a way of > creating the zip file in a sort of tmp directory and send it via > send_file from the tmp path. I don''t know when the file transfer is > over to delete the zip file and having a cron job to delete zip files > is not an option (disk space could be surpassed by the zip file and > the user will have to wait for it to be deleted to be able to create > new files). Can anyone point me in the right direction please. Thanks, > > El�asI dont''know how to do it in RoR (i''m a newbie) but wen i was using the old ASP there was an "onSessionEnd" where you can script some task to do when a session end (both for logout or timeout) You can just bind the zip to a session and when the session end you can delete the file -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I have been doing some research and only found about using cron jobs to do the cleaning (a point I discussed on my initial message) and also found this: There is an send_file option: :stream - whether to send the file to the user agent as it is read (true) or to read the entire file before sending (false). Defaults to true. When U set :stream => false U can delete the file just after send_file return. I wonder if someone has used this before and if there is any disadvantage to this approach. Thanks again, Elías On Mar 26, 4:41 am, "Simone R." <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Elias Orozco wrote: > > Hello guys, > > > I am having the option to download certain folders on my app in zip > > format. So every time a user requests one I''m doing a system call to > > zip the folder (ex: system(''cd ''+path+'' && zip ...) and then the > > send_file method to send it. > > > What happens is that I''m keeping track of disk space so I need to > > delete the zip immediately. I was wondering if there is a way of > > creating the zip file in a sort of tmp directory and send it via > > send_file from the tmp path. I don''t know when the file transfer is > > over to delete the zip file and having a cron job to delete zip files > > is not an option (disk space could be surpassed by the zip file and > > the user will have to wait for it to be deleted to be able to create > > new files). Can anyone point me in the right direction please. Thanks, > > > El as > > I dont''know how to do it in RoR (i''m a newbie) but wen i was using the > old ASP there was an "onSessionEnd" where you can script some task to do > when a session end (both for logout or timeout) > > You can just bind the zip to a session and when the session end you can > delete the file > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---