filepath = self.class.instance_variable_get(:@filename)
# puts" #{:@filename}"
qget = params['clientquery']
if !qget.nil? then
begin
systemCmd = "bash /home/abc/t.sh \"#{qget}\" \"#{filepath}\""
puts systemCmd
output = system("#{systemCmd} 2>&1")
data = File.read(filepath)
send_data data, filename: File.basename(filepath),
type: 'application/csv',
disposition: 'attachment'
ensure
# delfile = File.basename("/tmp/download.csv")
FileUtils.remove_entry_secure File.basename("/tmp/download.csv")
# File.delete(delfile)
# redirect_to '/report'
end
FileUtils.remove_entry_secure File.basename(" /tmp/download.csv")使用此代码我尝试在下载后删除文件但它无法正常工作
如果我评论行FileUtils.remove_entry_secure File.basename(" /tmp/download.csv")
已下载文件,但我想在下载文件后删除该文件
答案 0 :(得分:0)