Skip to content

Commit

Permalink
Fix ActiveStorage service vs local file handling
Browse files Browse the repository at this point in the history
  • Loading branch information
forsbergplustwo committed Sep 21, 2023
1 parent da2a141 commit ce4b4a1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/models/import/adaptor/csv_file.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require "zip"
require "csvreader"

class Import::Adaptor::CsvFile
Expand Down Expand Up @@ -131,10 +132,15 @@ def prepared_csv_file
return @prepared_csv_file if @prepared_csv_file

file = @import.payouts_file

@temp_files[:raw] = Tempfile.new("raw")
@temp_files[:raw].write(file.download.force_encoding("UTF-8"))
@temp_files[:raw].rewind

if zipped?(file.content_type)
extracted_zip_file(ActiveStorage::Blob.service.path_for(file.key))
extracted_zip_file(@temp_files[:raw].path)
else
ActiveStorage::Blob.service.path_for(file.key)
@temp_files[:raw].path
end
end

Expand Down

0 comments on commit ce4b4a1

Please sign in to comment.