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?
|
if attachment.persisted?
|
||||||
{}
|
{}
|
||||||
else
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -64,9 +64,11 @@ module Dunlop::TargetFileModel
|
|||||||
end
|
end
|
||||||
|
|
||||||
def local_target_filename
|
def local_target_filename
|
||||||
|
@local_target_filename ||= begin
|
||||||
result = File.join(Rails.application.config.working_path, target_basename)
|
result = File.join(Rails.application.config.working_path, target_basename)
|
||||||
gzip_file? ? result + ".gz" : result
|
gzip_file? ? result + ".gz" : result
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Target file basename used on creation to deliver the desired file_name.
|
# Target file basename used on creation to deliver the desired file_name.
|
||||||
# On actul persisted records this method cannot be used for naming. Then
|
# On actul persisted records this method cannot be used for naming. Then
|
||||||
@@ -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
|
# 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
|
end
|
||||||
|
|
||||||
# Implement in Subclass. Example:
|
# Implement #data or this method in Subclass. Example:
|
||||||
# CsvBuilder::BladiBla.new(resource).data
|
# CsvBuilder::BladiBla.new(resource).data
|
||||||
def generate_file
|
def generate_file
|
||||||
working_file.puts builder.data
|
working_file.puts builder.data
|
||||||
|
|||||||
Reference in New Issue
Block a user