I've checked out this repository and wrote the below simple test.rb, while using the below image:
require 'mongoid-grid_fs'
Mongoid.configure do |config|
config.connect_to('mongoid-grid_fs_test')
end
file = File.open('./signature.png')
grid_file = Mongoid::GridFs.put(file.path)
If I execute this with bundle exec ruby test.rb, I'm getting the following exception.
Am I doing something wrong or overlooking something?
❯ bundle exec ruby test.rb
/usr/local/lib/ruby/gems/2.1.0/gems/bson-3.1.2/lib/bson/binary.rb:137:in `encode': "\x89" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
from /usr/local/lib/ruby/gems/2.1.0/gems/bson-3.1.2/lib/bson/binary.rb:137:in `block in to_bson'
from /usr/local/lib/ruby/gems/2.1.0/gems/bson-3.1.2/lib/bson/encodable.rb:81:in `encode_binary_data_with_placeholder'
from /usr/local/lib/ruby/gems/2.1.0/gems/bson-3.1.2/lib/bson/binary.rb:134:in `to_bson'
from /usr/local/lib/ruby/gems/2.1.0/gems/bson-3.1.2/lib/bson/hash.rb:46:in `block (2 levels) in to_bson'
from /usr/local/lib/ruby/gems/2.1.0/gems/bson-3.1.2/lib/bson/hash.rb:43:in `each'
from /usr/local/lib/ruby/gems/2.1.0/gems/bson-3.1.2/lib/bson/hash.rb:43:in `block in to_bson'
from /usr/local/lib/ruby/gems/2.1.0/gems/bson-3.1.2/lib/bson/encodable.rb:57:in `encode_with_placeholder_and_null'
from /usr/local/lib/ruby/gems/2.1.0/gems/bson-3.1.2/lib/bson/hash.rb:42:in `to_bson'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/protocol/message.rb:166:in `block in serialize_documents'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/protocol/message.rb:165:in `each'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/protocol/message.rb:165:in `serialize_documents'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/protocol/message.rb:323:in `serialize'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/connection.rb:171:in `block in write'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/connection.rb:169:in `each'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/connection.rb:169:in `write'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/node.rb:590:in `block (2 levels) in flush'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/node.rb:182:in `block in ensure_connected'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/node.rb:115:in `block in connection'
from /usr/local/lib/ruby/gems/2.1.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:64:in `block (2 levels) in with'
from /usr/local/lib/ruby/gems/2.1.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:63:in `handle_interrupt'
from /usr/local/lib/ruby/gems/2.1.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:63:in `block in with'
from /usr/local/lib/ruby/gems/2.1.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:60:in `handle_interrupt'
from /usr/local/lib/ruby/gems/2.1.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:60:in `with'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/node.rb:114:in `connection'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/node.rb:178:in `ensure_connected'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/node.rb:589:in `block in flush'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/node.rb:617:in `block in logging'
from /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.3/lib/active_support/notifications.rb:164:in `block in instrument'
from /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.3/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
from /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.3/lib/active_support/notifications.rb:164:in `instrument'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/instrumentable.rb:31:in `instrument'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/node.rb:616:in `logging'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/node.rb:587:in `flush'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/node.rb:358:in `pipeline'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/operation/write.rb:47:in `execute'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/node.rb:665:in `write'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/node.rb:273:in `insert'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/collection.rb:128:in `block (2 levels) in insert'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/cluster.rb:249:in `block in with_primary'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/node.rb:204:in `block in ensure_primary'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/executable.rb:25:in `execute'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/node.rb:203:in `ensure_primary'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/cluster.rb:248:in `with_primary'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/collection.rb:127:in `block in insert'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/retryable.rb:30:in `call'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/retryable.rb:30:in `with_retry'
from /usr/local/lib/ruby/gems/2.1.0/gems/moped-2.0.6/lib/moped/collection.rb:125:in `insert'
from /usr/local/lib/ruby/gems/2.1.0/gems/mongoid-4.0.2/lib/mongoid/query_cache.rb:117:in `insert_with_clear_cache'
from /usr/local/lib/ruby/gems/2.1.0/gems/mongoid-4.0.2/lib/mongoid/persistable/creatable.rb:79:in `insert_as_root'
from /usr/local/lib/ruby/gems/2.1.0/gems/mongoid-4.0.2/lib/mongoid/persistable/creatable.rb:27:in `block in insert'
from /usr/local/lib/ruby/gems/2.1.0/gems/mongoid-4.0.2/lib/mongoid/persistable/creatable.rb:118:in `block (2 levels) in prepare_insert'
from /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:84:in `run_callbacks'
from /usr/local/lib/ruby/gems/2.1.0/gems/mongoid-4.0.2/lib/mongoid/interceptable.rb:138:in `run_callbacks'
from /usr/local/lib/ruby/gems/2.1.0/gems/mongoid-4.0.2/lib/mongoid/persistable/creatable.rb:117:in `block in prepare_insert'
from /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:84:in `run_callbacks'
from /usr/local/lib/ruby/gems/2.1.0/gems/mongoid-4.0.2/lib/mongoid/interceptable.rb:138:in `run_callbacks'
from /usr/local/lib/ruby/gems/2.1.0/gems/mongoid-4.0.2/lib/mongoid/persistable/creatable.rb:116:in `prepare_insert'
from /usr/local/lib/ruby/gems/2.1.0/gems/mongoid-4.0.2/lib/mongoid/persistable/creatable.rb:23:in `insert'
from /usr/local/lib/ruby/gems/2.1.0/gems/mongoid-4.0.2/lib/mongoid/persistable/savable.rb:23:in `save'
from /usr/local/lib/ruby/gems/2.1.0/gems/mongoid-4.0.2/lib/mongoid/persistable/savable.rb:44:in `save!'
from /Users/tdegrunt/Development/Personal/mongoid-grid_fs/lib/mongoid/grid_fs.rb:154:in `block (2 levels) in put'
from /Users/tdegrunt/Development/Personal/mongoid-grid_fs/lib/mongoid/grid_fs.rb:479:in `call'
from /Users/tdegrunt/Development/Personal/mongoid-grid_fs/lib/mongoid/grid_fs.rb:479:in `chunking'
from /Users/tdegrunt/Development/Personal/mongoid-grid_fs/lib/mongoid/grid_fs.rb:147:in `block in put'
from /Users/tdegrunt/Development/Personal/mongoid-grid_fs/lib/mongoid/grid_fs.rb:458:in `call'
from /Users/tdegrunt/Development/Personal/mongoid-grid_fs/lib/mongoid/grid_fs.rb:458:in `block in reading'
from /Users/tdegrunt/Development/Personal/mongoid-grid_fs/lib/mongoid/grid_fs.rb:457:in `open'
from /Users/tdegrunt/Development/Personal/mongoid-grid_fs/lib/mongoid/grid_fs.rb:457:in `reading'
from /Users/tdegrunt/Development/Personal/mongoid-grid_fs/lib/mongoid/grid_fs.rb:136:in `put'
from (eval):2:in `put'
from test.rb:8:in `<main>'
Hi,
I've checked out this repository and wrote the below simple test.rb, while using the below image:
If I execute this with
bundle exec ruby test.rb
, I'm getting the following exception. Am I doing something wrong or overlooking something?Here's the output of my bash
locale
:The image used (via wikipedia):
For completeness here's the output of
bundle list
: