Cant figure out how to format post request to post image to twitter


I’m successfully posting a tweet via:
response = access_token.request(:post,, :status=>“tweet”).

This line was taken and altered from the examples at using their ruby Oauth example.

But what I want to do is:
response = access_token.request(:post,, :media=>“filepath/file.png”).

But I get: {“request”:"/1.1/media/upload.json",“error”:“media type unrecognized.”}

I’m thinking I’m not formatting my request correctly, with content-type and so on.
Can someone give me an example? I only find twurl command examples on twitter dev.
But currently on a old production server with ruby 1.8.7 so twurl wont install.