How to save image in blob field using watir?
Take a look at this quick example that I wrote. Essentially, I just find the image I want to use id and then get its source. Then I open a temporary file to store the contents of the image and finally I open the URL of this src and write it to the temp file. The advantage of using tempfile is the lack of cleanup.
require 'watir-webdriver' require 'open-uri' require 'tempfile' browser = Watir::Browser.new :firefox browser.goto("http://www.reddit.com") img = browser.image(:id, "header-img").src tempFile = Tempfile.new('tempImage') open(img, 'rb') do |image| tempFile.write(image.read) end tempFile.rewind puts tempFile.read ###Make your database call here, simply save this tempFile.read as a blob tempFile.close tempFile.unlink # completely deletes the temp file browser.close In this example, I just get the reddit logo and print the binary data to the screen. You never indicated which database you are using, so I didn’t want to assume, but instead of doing “puts”, you can make your DB call there.