Eric Scott
Eric Scott

Reputation: 11

Posting a photo to the Facebook Open Graph from Heroku, using RoR, FbGraph Gem, and S3

I am trying to allow a user to share a photo on his Facebook wall. I use Paperclip to store all of my app's photos on S3. So in the below example @photo.image.url is the S3 url of an image that I want to post in some_album. Using the fb_graph gem this is relatively easy on localhost. In my controller I have:

    the_photo = open(@photo.image.url)
    some_album.photo!(
      :access_token => access_token,
      :source => the_photo
    )

the_photo's class on localhost is "Tempfile".

On heroku things get tricky. Using the same code two (seemingly related) things happen. First, the_photo is class type "stringIO". Second when FbGraph posts to Facebook I get the following error:

FbGraph::InvalidRequest (OAuthException :: (#324) Requires upload file):

Heres a few bullet points of facts that might also help:

Any help/thoughts/work arounds/questions would be greatly appreciated.

Upvotes: 0

Views: 1390

Answers (1)

Eric Scott
Eric Scott

Reputation: 11

I am not sure why this did the trick but this worked for me:

some_album.photo!(
  :access_token => access_token,
  :source => open(@photo.image.url)
)

as opposed to setting a variable photo_response = open(@photo.image.url).

Upvotes: 1

Related Questions