NoMethodError (undefined method unpack' for #<Array:0x48cbff0>): c:/ruby/lib/ruby/1.8/base64.rb:59:indecode64’
From this is looks to me like some code is attempting to decode the
image data from Base64. Are you sure your image data is encoded using
Base64? I tend to doubt it. MS-SQL is likely just storing the raw binary
data. So it makes sense the you would have an array of bytes.
It would be helpful if you could post the code that you’re using to
display the image. Normally in RoR there is a method that returns the
raw image data from a request with the proper content-type header. For
example the content-type header for a JPEG would be image/jpeg.
Somehow your application needs to tell the browser what the binary data
represents. It could be pretty much anything (JPEG, GIF, PDF, etc). This
is typically accomplished using the send_data method.
Here’s an example:
def sales_graph
png_data = Sales.plot_for(Date.today.month)
send_data(png_data, :type => “image/png”, :disposition => “inline”)
end
Günther Lackner wrote:
Hello!
I need to display images stored in a MS-SQL database but I get the
following error:
NoMethodError (undefined method unpack' for #<Array:0x48cbff0>): c:/ruby/lib/ruby/1.8/base64.rb:59:indecode64’
You might be right, it could be a byte array… but how can I display
it??
best regards
lacky
Robert W. wrote:
NoMethodError (undefined method unpack' for #<Array:0x48cbff0>): c:/ruby/lib/ruby/1.8/base64.rb:59:indecode64’
From this is looks to me like some code is attempting to decode the
image data from Base64. Are you sure your image data is encoded using
Base64? I tend to doubt it. MS-SQL is likely just storing the raw binary
data. So it makes sense the you would have an array of bytes.
It would be helpful if you could post the code that you’re using to
display the image. Normally in RoR there is a method that returns the
raw image data from a request with the proper content-type header. For
example the content-type header for a JPEG would be image/jpeg.
Somehow your application needs to tell the browser what the binary data
represents. It could be pretty much anything (JPEG, GIF, PDF, etc). This
is typically accomplished using the send_data method.
Here’s an example:
def sales_graph
png_data = Sales.plot_for(Date.today.month)
send_data(png_data, :type => “image/png”, :disposition => “inline”)
end
Günther Lackner wrote:
Hello!
I need to display images stored in a MS-SQL database but I get the
following error:
NoMethodError (undefined method unpack' for #<Array:0x48cbff0>): c:/ruby/lib/ruby/1.8/base64.rb:59:indecode64’