bteitelb-paperclip 2.3.1.10 → 2.3.1.11

Sign up to get free protection for your applications and to get access to all the features.
data/lib/paperclip.rb CHANGED
@@ -94,7 +94,7 @@ module Paperclip
94
94
  # Paperclip.options[:log_command] is set to true (defaults to false). This
95
95
  # will only log if logging in general is set to true as well.
96
96
  def run cmd, params = "", expected_outcodes = 0
97
- command = %Q[#{path_for_command(cmd)} #{params}].gsub(/\s+/, " ")
97
+ command = %Q["#{path_for_command(cmd)}" #{params}].gsub(/\s+/, " ")
98
98
  command = "#{command} 2>#{bit_bucket}" if Paperclip.options[:swallow_stderr]
99
99
  Paperclip.log(command) if Paperclip.options[:log_command]
100
100
  output = `#{command}`
@@ -271,6 +271,15 @@ module Paperclip
271
271
  # Determines whether or not the attachment is an image based on the content_type
272
272
  def image?
273
273
  !content_type.nil? and !!content_type.match(%r{\Aimage/})
274
+
275
+ # Fix content type when it's application/octet-stream
276
+ if content_type.to_s.strip == 'application/octet-stream'
277
+ mime_type = MIME::Types.type_for(uploaded_file.original_filename.strip).to_s
278
+ end
279
+ instance_write(:content_type, uploaded_file.content_type.to_s.strip)
280
+ instance_write(:file_size, uploaded_file.size.to_i)
281
+ instance_write(:updated_at, Time.now)
282
+
274
283
  end
275
284
 
276
285
  # Writes the attachment-specific attribute on the instance. For example,
@@ -436,6 +445,11 @@ module Paperclip
436
445
  Paperclip::Interpolations.interpolate(pattern, self, style)
437
446
  end
438
447
 
448
+ def mime_type
449
+ uploaded_file.content_type = MIME::Types.type_for(instance_read(:file_name)).to_s
450
+
451
+ end
452
+
439
453
  def dimensions style = default_style
440
454
  return [nil,nil] unless image?
441
455
  return @dimensions[style] unless @dimensions[style].nil?
@@ -15,8 +15,13 @@ module Paperclip
15
15
  # File or path.
16
16
  def self.from_file file
17
17
  file = file.path if file.respond_to? "path"
18
+ if RUBY_PLATFORM =~ /mswin32/
19
+ args = %Q[-format ^%wx^%h "#{file}"[0]]
20
+ else
21
+ args = %Q[-format "%wx%h" "#{file}"[0]]
22
+ end
18
23
  geometry = begin
19
- Paperclip.run("identify", %Q[-format "%wx%h" "#{file}"[0]])
24
+ Paperclip.run("identify", args)
20
25
  rescue PaperclipCommandLineError
21
26
  ""
22
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bteitelb-paperclip
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1.10
4
+ version: 2.3.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Yurek