[英]delete/remove temp zip file in ruby on rails
i am creating temp zip
file in rails tmp
directory as follows:- 我在rails
tmp
目录中创建temp zip
文件,如下所示:
zipfile_name = Rails.root.join("tmp/abc.zip")
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
Dir[File.join(data, '**',)].each do |file|
zipfile.add(file.sub(dir+"/", ''), file)
end
end
zip_data = File.read(zipfile_name) # sending zip file.
zipfile_name.try(:unlink)` # try to remove or unlink the zip but not working.
temp zipfile_name
was abc.zip20140816-8931-1yl3g60 and i want to delete it after sending but it's not found. 临时
zipfile_name
为abc.zip20140816-8931-1yl3g60 ,我想在发送后将其删除,但找不到。
File.delete(zipfile_name)
尝试文件删除命令,应该可以解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.