Fumiya Fumiya - 2 months ago 7
Ruby Question

Rails4 How can I tweet with a picture from a website with sferik / twitter gem?

I know i can tweet with update method like

client.update("I'm tweeting with @gem!")

but how can i tweet with a picture from a website? Can I use
method with


The update_with_media method expects an image file

# @param media [File, Hash] A File object with your picture (PNG, JPEG or GIF)
# ...
# ...
def update_with_media(status, media, options = {})

Source: https://github.com/sferik/twitter/blob/master/lib/twitter/rest/tweets.rb#L224

To use an URL of a website for the media you should use another gem that captures a URL to an image (e.g. https://github.com/csquared/IMGKit) and then send that image with the update_with_media method.