Download CSV and process with Paperclip without saving CSV

I currently allow users to download CSV files, process them, save entries in a database based on the content, and then return and clear the CSV. I am wondering if it is possible to load and process while storing CSV in memory without touching the disk?

How to tell paperclip not to save the source file?

... seems to suggest that turning off a field from migration will do it, but I have no luck with this approach. Any ideas?

+4
source share
1 answer

The whole point of a paper clip is to save the file. You may have something like the following as your action and completely skip using a paper clip.

def upload CSV.parse(params[:file].read) do |row| # do whatever you need to do with the row end end 

with this form:

 <%= form_tag('/path/to/upload') do %> <%= file_field_tag :file %> <%= submit_tag %> <% end %> 
+5
source

All Articles