Add .xlsx unzip unmodified support since .xlsx files can be a natural zip file
This commit is contained in:
@@ -48,7 +48,8 @@ module Dunlop::SourceFileModel
|
||||
|
||||
def unzip_working_file
|
||||
source_path = if original_file.try(:options).try(:[], :storage) == :s3
|
||||
temp = Tempfile.new 'temp' # keep reference for tempfile till unzip completed
|
||||
filename = original_file.original_filename.to_s
|
||||
temp = Tempfile.new([filename, File.extname(filename)]) # keep reference for tempfile till unzip completed and keep extension preserved
|
||||
temp.binmode
|
||||
open( original_file.expiring_url ) { |data| temp.write data.read }
|
||||
temp.close
|
||||
|
||||
@@ -184,9 +184,10 @@ module Dunlop::TargetFileModel
|
||||
def activate_dunlop!
|
||||
end
|
||||
|
||||
def generate!(resource = nil)
|
||||
# Allow resource as argument. Changed from resource to rsrc to be sure to avoid method naming collision confusion
|
||||
def generate!(rsrc = nil)
|
||||
new_record = create
|
||||
new_record.resource = resource if resource.present?
|
||||
new_record.resource = rsrc if rsrc.present?
|
||||
new_record.execute_generation_process
|
||||
new_record
|
||||
end
|
||||
|
||||
@@ -3,7 +3,11 @@ module Dunlop::FileZip
|
||||
def self.unzip(zipped_filename, unzipped_filename)
|
||||
case self.mime_type(zipped_filename)
|
||||
when "application/zip"
|
||||
%x[ unzip -p #{zipped_filename} > #{unzipped_filename} ]
|
||||
if zipped_filename.end_with?('.xlsx') # .xlsx IS a zipfile
|
||||
%x[ cp #{zipped_filename} #{unzipped_filename} ]
|
||||
else
|
||||
%x[ unzip -p #{zipped_filename} > #{unzipped_filename} ]
|
||||
end
|
||||
when "application/x-gzip"
|
||||
%x[ gzip -c -d #{zipped_filename} > #{unzipped_filename} ]
|
||||
when "text/plain"
|
||||
|
||||
Reference in New Issue
Block a user