Use .gz extension for attachment filename if it is supplied
This commit is contained in:
@@ -7,7 +7,7 @@ module Dunlop::TargetFileModel
|
||||
if attachment.persisted?
|
||||
{}
|
||||
else
|
||||
{'Content-Disposition' => %|attachment; filename="#{attachment.target_basename}"|} # can be resource based and only available on initialization. Therefore persisted?
|
||||
{'Content-Disposition' => %|attachment; filename="#{File.basename(attachment.local_target_filename)}"|} # can be resource based and only available on initialization. Therefore persisted?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -64,8 +64,10 @@ module Dunlop::TargetFileModel
|
||||
end
|
||||
|
||||
def local_target_filename
|
||||
result = File.join(Rails.application.config.working_path, target_basename)
|
||||
gzip_file? ? result + ".gz" : result
|
||||
@local_target_filename ||= begin
|
||||
result = File.join(Rails.application.config.working_path, target_basename)
|
||||
gzip_file? ? result + ".gz" : result
|
||||
end
|
||||
end
|
||||
|
||||
# Target file basename used on creation to deliver the desired file_name.
|
||||
@@ -85,7 +87,7 @@ module Dunlop::TargetFileModel
|
||||
# hook to implement post generation actions like sending by email and/or to other systems by means of web call and/or to create a transfer instance
|
||||
end
|
||||
|
||||
# Implement in Subclass. Example:
|
||||
# Implement #data or this method in Subclass. Example:
|
||||
# CsvBuilder::BladiBla.new(resource).data
|
||||
def generate_file
|
||||
working_file.puts builder.data
|
||||
|
||||
Reference in New Issue
Block a user