paperclip_database_storage 3.0.3 → 3.0.4
Sign up to get free protection for your applications and to get access to all the features.
@@ -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
|