Wednesday, March 12, 2008

Posting binary data using ruby

data = File.read('sample.xml')
url = URI.parse('http://localhost:3000/update')
http = Net::HTTP.new(url.host, url.port)
response, body = http.post(url.path, data, {'Content-type'=>'text/xml;
charset=utf-8'})

Monday, February 18, 2008

Code: Auto-thumbnail using Magick


def auto_thumbnail
@board = Board.find(params["id"])
pic = Magick::Image.read(@board.thumbnail_image).first
thumb = pic.resize(200, 145)
@response.headers["Content-type"]= thumb.mime_type
render :text => thumb.to_blob
end