Employer form mostly working with persist to db
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
module BenefitsWordDoc
|
||||
class MapEmployerLogo
|
||||
|
||||
def initialize(process, word_doc)
|
||||
@process = process
|
||||
@word_doc = word_doc
|
||||
end
|
||||
|
||||
def call
|
||||
extracted_images = []
|
||||
Zip::File.open(@word_doc) do |zip_file|
|
||||
zip_file.each do |entry|
|
||||
if entry.name.start_with?('word/media/') && !entry.directory?
|
||||
filename = @process.employer_name.titleize.gsub(/\s+/, '').concat("Logo.png")
|
||||
image_data = entry.get_input_stream.read
|
||||
extracted_images << { filename: filename, data: image_data }
|
||||
end
|
||||
end
|
||||
end
|
||||
if extracted_images.length > 1
|
||||
employer_logo = extracted_images.last
|
||||
@process.employer_logo = employer_logo[:filename]
|
||||
# same file logic
|
||||
end
|
||||
@process.save
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user