Why are RackMultipart* files persisting in my Rails /tmp directory?

后端 未结 3 1238
一整个雨季
一整个雨季 2021-02-05 17:44

I\'m using Paperclip (2.3) to handle image uploads on a Rails 3.0.3 app running on Ubuntu. Paperclip is handling the uploads as advertised BUT the RackMultipart* files that are

3条回答
  •  春和景丽
    2021-02-05 18:23

    UPDATE: Problem should be resolved in rack-1.6.0.beta2. I see it's already being used in Rails 4.2.0.rc2.

    Below workaround served me well for almost a year:

    I've added this at the end of controller action that accepts file uploads:

    Thread.new { GC.start }
    

    This triggers Garbage Collection of unused Rack::Request objects which also deletes associated temp files. Note it doesn't sweep temp file of current request, but it does remove previous files, and prevents them from accumulating.

提交回复
热议问题