Reputation: 6851
I would like to save CSV files that users upload to a blob. I would than like to retrieve the CSV file out of the blob in a format that I can use with the ruby CSV library. Any ideas on how I can accomplish that?
Upvotes: 2
Views: 3106
Reputation: 13531
You'll have to add a field to your model with datatype :text
(because that's what a CSV is, not binary). Let's say your model is called Record
and the field is called csv
:
record = Record.new
record.csv = File.read 'path/to/csv'
record.save
#... later...
CSV.parse record.csv # => here's your csv
Questions?
Upvotes: 1