I'm trying to display a generated .png plot via send_data(), but it
results in a server error "invalid byte sequence in US-ASCII" error.
I'm pretty sure this means that I need to specify the encoding
somewhere, but I haven't been able to figure out where or how to do so.
Some particulars:
I'm running gnuplot through a pipe to generate a plot in .png format.
(I've tested the code by writing its output to a file and displaying it
-- it works.) My Report model receives the .png image as a string:
class Report << ActiveRecord::Base
def imagedata
image = GnuPlot(@gnuplot_commands)
end
end
My Controller uses send_data() to serve up a page:
class ReportsController < ApplicationController
def plot
report = Report.find(params[:id])
send_data(report.imagedata, :type => 'image/gif')
end
end
[FWIW, without really understanding it, I also tried added an :encoding
=> 'utf8' to the send_data call -- no change.] Finally, my View presents
the result:
<img src="<%= url_for(:controller => 'reports', :action => 'plot')
-%>" />
However, the send_data() call results in a server error:
ArgumentError (invalid byte sequence in US-ASCII):
<internal:prelude>:8:in `synchronize'
.../Ruby/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
So the question: Where do I specify the encoding? And what encoding is
appropriate for a .png binary?
BTW:
"rails --version" => Rails 2.3.5
"ruby --version" => ruby 1.9.1p376
"mysqul --vesion" => Ver 14.14 Distrib 5.1.36
OS = Mac OS X 10.5.8
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment