I need to save image from file to PostgreSQL database as binary. Trying to do it like this:
image_file = File.open("image.png", "rb") { |file| file.read }
Image.create(product_id: product_id, image: image_file)
This code gives me the following error:
string contains null byte
Using paperclip or similar, or converting binary to base64 are not an option.