lib/mongo_grid.rb in mongo_grid-0.2.9 vs lib/mongo_grid.rb in mongo_grid-0.3.0
- old
+ new
@@ -1,6 +1,5 @@
-require 'zbox'
require 'mongo_grid/version'
#Dir[File.join(File.dirname(__FILE__), 'mongo_grid', '*.rb')].each do |extension|
# require extension
#end
@@ -35,11 +34,16 @@
end
def uploadtogrid(upload,opts={})
filename=upload.original_filename
content_type=upload.content_type
- if /jpg|jpeg|png/ =~ content_type
- ::Zbox::Qm.resize(upload.tempfile.path,opts)
+ if /jpg|jpeg|png/ =~ content_type
+ if opts[:width]
+ %x[resize -fixed -w #{opts[:width]} #{upload.tempfile.path}]
+ else
+ %x[resize -fixed #{upload.tempfile.path}]
+ end
+
end
data = File.open(upload.tempfile.path)
length=File.size(upload.tempfile.path)
gfile = ::Mongo::Grid::File.new(data,filename: filename, metadata: {content_type: content_type,length: length})
gid = grid.insert_one(gfile)