ArgumentError (string contains null byte) -- file upload pro


#1

Hi,

Controller code:
if params[:main_image]
image = Image.new
image.blob = params[:main_image].read
@product.main_image.destroy if @product.main_image
@product.main_image = image
end

When I try to display the image using send_data, I get the following
error:
ArgumentError (string contains null byte):
.//vendor/rails/actionpack/lib/action_controller/streaming.rb:55:in
file?' .//vendor/rails/actionpack/lib/action_controller/streaming.rb:55:insend_file’
.//app/controllers/images_controller.rb:5:in `show’

Here’s the image controller:
class ImagesController < ApplicationController
def show
image = Image.find params[:id]
send_file image.blob, :type => ‘image/jpeg’, :disposition =>
‘inline’
end
end

Any ideas?
Joe


#2

Gah, I wanted send_data, not send_file.