In Ruby, how can I update the avatar / background image file.jpg in a folder?

55 views Asked by At

My image files are in a folder titled "avis" and each jpeg file inside has a title of "IMG_36754.JPG". The numbers are kind of random. My problem is that I can't get the client to update the avatar or the background image.

client = Twitter::REST::Client.new do |config|
    config.consumer_key        = "xxxxx"
    config.consumer_secret     = "xxxxx"
    config.access_token        = "xxxxx"
    config.access_token_secret = "xxxxx"
end

When I try the code below, I get an error that reads " No such file or directory @ rb_sysopen - IMG_7394.JPG (Errno::ENOENT)"

file5 = File.open(Dir.entries("avis").sample)

puts client.update_profile_image(file5)

When I use this code below, I get an error "No such file or directory @ rb_sysopen - avi (Errno::ENOENT)"

avis = Dir.entries("avis")

avi = avis.sample.to_s


file = File.read("avi","r")
puts client.update_profile_image(file)

I tried to make it so that it can get the image file from the folder and then have the update profile method use the image string to update, however it doesn't seem to work. please help, thanks.

0

There are 0 answers