Permalink
Browse files

Handle special cases when mime-types gem fails to recognize

  • Loading branch information...
1 parent 399e9d3 commit 15e5aa6e1e3563bbaf0f1575fc79527e9b90cc71 @steverandy committed Jul 15, 2012
Showing with 11 additions and 1 deletion.
  1. +11 −1 app/models/concen/grid_file.rb
@@ -50,7 +50,7 @@ def store(content, filename)
original_filename = filename.dup
file_extension = File.extname(original_filename).downcase
- content_type = MIME::Types.type_for(original_filename).first.to_s
+ content_type = content_type_for original_filename
# Pre generate ObjectId for the new GridFS file.
grid_id = BSON::ObjectId.new
@@ -65,6 +65,16 @@ def store(content, filename)
end
end
+ def content_type_for(filename)
+ content_type = MIME::Types.type_for(filename).first.to_s
+
+ # Special cases when mime-types fails to recognize
+ content_type = "video/mp4" if filename.include?(".mp4")
+ content_type = "video/x-m4v" if filename.include?(".m4v")
+
+ return content_type
+ end
+
protected
def destroy_gridfs

0 comments on commit 15e5aa6

Please sign in to comment.