When you close the Tempfile, be sure to pass true for unlink_now.

http://ruby-doc.org/stdlib/libdoc/tempfile/rdoc/classes/Tempfile.html#M004418

On Thu, Nov 11, 2010 at 2:33 PM, Christian Fazzini
<[email protected]> wrote:
> In video controller, create action. I am using FFMPEG to generate a
> thumbnail of videos that are uploaded.
>
> The tempfile is created as such:
>
> def create
>  ......
>  dst = Tempfile.new(basename)
>  dst.binmode
>
>  system("ffmpeg -itsoffset -4 -i #{file.path} -y -vcodec mjpeg -
> vframes 1 -an -f rawvideo #{File.expand_path(dst.path)}.png")
>  ....
> end
>
>
> As you can see from above, ffmpeg outputs a file to the var dst which
> is an instance of Tempfile. In console, when I do:
>
> ls /var/folders/uL/uL0bYOOZEZaJH5E+BmDJVE+++TI/-Tmp-/
>
> thumb20101111-989-1gflwhr.png
> thumb20101111-989-1pt72my.png
> thumb20101111-989-kjcsgd.png
> thumb20101111-989-3ocf15.png
> thumb20101111-989-10azwnn.png
> thumb20101111-989-7x11w7.png
>
> I see a bunch of files in the directory. It seems that rails did not
> automatically delete these temp files. Should I manually delete these
> files?
>
> I am worried that, if my temp dir fills up with temp files, it'll
> eventually take up most of the server space...
>
> Your thoughts on this matter?
>
> --
> 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 [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to