- 
                Notifications
    You must be signed in to change notification settings 
- Fork 31
Open
Labels
Description
Right now SolidusImporter::ProcessImport is reading the CSV file by doing a File.read on the import file path.
def scan
      data = CSV.parse(
        File.read(@import.file.path),
        headers: true,
        encoding: 'UTF-8',
        header_converters: ->(h) { h.strip }
      )
      prepare_rows(data)
endHowever, on some projects that path may not be available depending on which customizations have been applied to Paperclip or ActiveStorage.
On a project I'm working on the files are sent directly to AWS, even on development, and their bucket path is interpolated in such a way that the @import.file local path can't be determined.
Therefore it would be useful to allow user-customizable strategies for reading the content from the file. E.g.:
SolidusImporter.config do |c|
  c.import_file_reader = -> (import) {
     open(@import.file.public_url)
  }
end
def scan
      raw_content = SolidusImporter::Config.import_file_reader.call(@import)
      data = CSV.parse(
        raw_content,
        headers: true,
        encoding: 'UTF-8',
        header_converters: ->(h) { h.strip }
      )
      prepare_rows(data)
endOr any other approach may also be viable as long as we allow this to me easily customizable.