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 => (params[:filename] || attachment.attached.send(attachment.attached.attachment_definitions.select { |k, v| v[:storage] == :database }.keys.first).original_filename)
25
+ :filename => filename
20
26
  end
21
27
  end
@@ -1,3 +1,3 @@
1
1
  module PaperclipDatabaseStorage
2
- VERSION = "3.0.3" unless defined? PaperclipDatabaseStorage::VERSION
2
+ VERSION = "3.0.4" unless defined? PaperclipDatabaseStorage::VERSION
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip_database_storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: