Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

photo upload graph.put_photo #30

Closed
lucapinello opened this issue May 4, 2012 · 4 comments
Closed

photo upload graph.put_photo #30

lucapinello opened this issue May 4, 2012 · 4 comments

Comments

@lucapinello
Copy link

I am not able to upload any photo with the put_photo method.

In the documentation the first parameter is the filename, while in the method it seems a file-like object.

Passing a file like object as a first paramter (called image) I recevice an unicode conversion error.

Any idea how to fix this?

Thanks

@martey
Copy link
Member

martey commented May 7, 2012

In the documentation the first parameter is the filename, while in the method it seems a file-like object.

Which documentation is this? The method's docstring clearly states that it should be a Python file-like object. The official Graph API documentation states that the API endpoint (me/photos) needs multipart/form-data but the method takes care of converting this. Where is the reference to using filenames?

Passing a file like object as a first paramter (called image) I recevice an unicode conversion error.

Could you provide a traceback? The following code worked for me:

>>> import facebook
>>> graph = facebook.GraphAPI("[redacted access token]")
>>> graph.put_photo(open("test.jpg"), "this is a test upload...please feel free to ignore")
{u'post_id': u'1867_10100367232455011', u'id': u'10100367232430061'}

@lucapinello
Copy link
Author

Hi Martey!
Thanks a lot for the quick answer.

Sorry I was confused from the Readme.md where I saw:

Photo uploads:

graph = facebook.GraphAPI(oauth_access_token)
tags = json.dumps([{'x':50, 'y':50, tag_uid:12345}, {'x':10, 'y':60,
tag_text:'a turtle'}])
graph.put_photo('img.jpg', 'Look at this cool photo!',
album_id_or_None, tags=tags)

You should update it to avoid confusion.

I will try with a file like object and I'll let you know.

Thanks again.

Luca

2012/5/7 Martey Dodoo
reply@reply.github.com:

In the documentation the first parameter is the filename, while in the method it seems a file-like object.

Which documentation is this? The method's docstring clearly states that it should be a Python file-like object. The official Graph API documentation states that the API endpoint (me/photos) needs multipart/form-data but the method takes care of converting this. Where is the reference to using filenames?

Passing a file like object as a first paramter (called image) I recevice an unicode conversion error.

Could you provide a traceback? The following code worked for me:

>>> import facebook
>>> graph = facebook.GraphAPI("[redacted access token]")
>>> graph.put_photo(open("test.jpg"), "this is a test upload...please feel free to ignore")
{u'post_id': u'1867_10100367232455011', u'id': u'10100367232430061'}

Reply to this email directly or view it on GitHub:
#30 (comment)

@lucapinello
Copy link
Author

It worked perfectly, thanks again for your patience and for you great
job with this library.

Best,

Luca

2012/5/7 Luca Pinello lucapinello@gmail.com:

Hi Martey!
Thanks a lot for the quick answer.

Sorry I was confused from the Readme.md where I saw:

Photo uploads:

graph = facebook.GraphAPI(oauth_access_token)
tags = json.dumps([{'x':50, 'y':50, tag_uid:12345}, {'x':10, 'y':60,
tag_text:'a turtle'}])
graph.put_photo('img.jpg', 'Look at this cool photo!',
album_id_or_None, tags=tags)

You should update it to avoid confusion.

I will try with a file like object and I'll let you know.

Thanks again.

Luca

2012/5/7 Martey Dodoo
reply@reply.github.com:

In the documentation the first parameter is the filename, while in the method it seems a file-like object.

Which documentation is this? The method's docstring clearly states that it should be a Python file-like object. The official Graph API documentation states that the API endpoint (me/photos) needs multipart/form-data but the method takes care of converting this. Where is the reference to using filenames?

Passing a file like object as a first paramter (called image) I recevice an unicode conversion error.

Could you provide a traceback? The following code worked for me:

>>> import facebook
>>> graph = facebook.GraphAPI("[redacted access token]")
>>> graph.put_photo(open("test.jpg"), "this is a test upload...please feel free to ignore")
{u'post_id': u'1867_10100367232455011', u'id': u'10100367232430061'}

Reply to this email directly or view it on GitHub:
#30 (comment)

martey added a commit that referenced this issue May 10, 2012
Clarify put_photo method usage (per issue #30), and update link to
Facebook's JavaScript SDK Github repo.
@martey
Copy link
Member

martey commented May 10, 2012

Thanks, Luca. The README has been updated in commit c92fa6a.

@martey martey closed this as completed May 10, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants