ruby on rails 3 - how to remove the file after download in specified path -
filepath = self.class.instance_variable_get(:@filename) # puts" #{:@filename}" qget = params['clientquery'] if !qget.nil? 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") using code try remove file after downloading not working
if comment line fileutils.remove_entry_secure file.basename("/tmp/download.csv")
the file downloaded want remove file after download file
i think permission problem.could please verify permission /tmp folder.
because fileutils.remove_entry_secure method check permission,user , group , remove.
please refer click here
Comments
Post a Comment