Created
May 19, 2011 05:41
-
-
Save ferrous26/980256 to your computer and use it in GitHub Desktop.
Problem in MacRuby somewhere...but where?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
require 'rubygems' | |
require 'restclient' | |
# setup db | |
DB = 'http://127.0.0.1:5984/test' | |
RestClient.delete DB rescue nil | |
RestClient.put DB, {}.to_json | |
# setup a document | |
doc = { '_id' => 'test' } | |
resp = JSON.parse RestClient.put("#{DB}/test", doc.to_json) | |
# prepare the document | |
image = IO.read '/Applications/Mail.app/Contents/Resources/AccountPreferences.tiff' | |
# put it in the db | |
RestClient.put( | |
"#{DB}/test/#{resp['_id']}/test.tiff?rev=#{resp['rev']}", | |
image, | |
content_type:'image/tiff' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This works with CRuby, but not on MacRuby. I haven't figured out why yet, but I think it losing some informating somewhere in net/http when it makes the PUT request.