def scan
data = CSV.parse(
File.read(@import.file.path),
headers: true,
encoding: 'UTF-8',
header_converters: ->(h) { h.strip }
)
prepare_rows(data)
end
However, 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)
end
Or any other approach may also be viable as long as we allow this to me easily customizable.
This issue has been automatically marked as stale because it has not had recent activity. It might be closed if no further activity occurs. Thank you for your contributions.
Right now
SolidusImporter::ProcessImport
is reading the CSV file by doing aFile.read
on the import file path.However, 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.:
Or any other approach may also be viable as long as we allow this to me easily customizable.