paperclip_database_storage 3.0.3 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,9 +13,15 @@ class PaperclipDatabaseStorage::AttachmentsController < ApplicationController
|
|
13
13
|
raise ActionController::RoutingError.new('Too many images found. Check your route definition') if attachments.length > 1
|
14
14
|
|
15
15
|
attachment = attachments.first
|
16
|
+
|
17
|
+
original_filename = attachment.attached.send(attachment.attached.attachment_definitions.select { |k, v| v[:storage] == :database }.keys.first).original_filename
|
18
|
+
original_extension = File.extname(original_filename)
|
19
|
+
filename = params[:filename] || original_filename
|
20
|
+
filename = "#{filename}#{original_extension}" unless filename =~ /#{original_extension}$/
|
21
|
+
|
16
22
|
send_data attachment.file_data,
|
17
23
|
:type => attachment.content_type,
|
18
24
|
:disposition => (attachment.content_type.strip =~ /^image/ ? 'inline' : 'attachment'),
|
19
|
-
:filename =>
|
25
|
+
:filename => filename
|
20
26
|
end
|
21
27
|
end
|