Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Mime::Type#types_for should read from file_name not path

  • Loading branch information...
commit 4a4e147520ec50fb677f5220ba4a61631c792ab6 1 parent 24518be
@maurcs maurcs authored
Showing with 3 additions and 3 deletions.
  1. +1 −1  grip.gemspec
  2. +2 −2 lib/grip/attachment.rb
View
2  grip.gemspec
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["twoism", "jnunemaker"]
- s.date = %q{2010-01-31}
+ s.date = %q{2010-02-16}
s.description = %q{GridFS attachments for MongoMapper}
s.email = %q{signalstatic@gmail.com}
s.extra_rdoc_files = [
View
4 lib/grip/attachment.rb
@@ -27,7 +27,7 @@ def file=new_file
self.file_name = new_file.is_a?(Tempfile) ? new_file.original_filename : File.basename(new_file.path)
self.file_size = File.size(new_file.path)
- self.content_type = MIME::Types.type_for(new_file.path)
+ self.content_type = MIME::Types.type_for(self.file_name)
write_to_grid self, new_file
end
@@ -60,7 +60,7 @@ def build_variants
new_attachment.owner_type = self.class.to_s
new_attachment.file_name = File.basename(file_hash[:uploaded_file].path)
new_attachment.file_size = File.size(file_hash[:resized_file].path)
- new_attachment.content_type = MIME::Types.type_for(file_hash[:uploaded_file].path)[0].content_type
+ new_attachment.content_type = MIME::Types.type_for(new_attachment.file_name)
new_attachment.save!
write_to_grid new_attachment, file_hash[:resized_file]
Please sign in to comment.
Something went wrong with that request. Please try again.