Deleting files after they are sent via send_file

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,


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,