Skip to content

Commit

Permalink
Image needs to be a file-like object to support thing like App Engine
Browse files Browse the repository at this point in the history
Removed an extra print
  • Loading branch information
subssn21 committed Apr 12, 2011
1 parent e942566 commit 67201e9
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/facebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,21 +155,18 @@ def delete_object(self, id):
"""Deletes the object with the given ID from the graph."""
self.request(id, post_args={"method": "delete"})

def put_photo(self, image_path, message=None, album_id=None, **kwargs):
def put_photo(self, image, message=None, album_id=None, **kwargs):
"""Uploads an image using multipart/form-data
image=File like object for the image
message=Caption for your image
album_id=None posts to /me/photos which uses or creates and uses
These can be passed as kwargs
source=The file-like object to read from. When using open make sure you open("filename", "rb")
message=Caption of the photo
an album for your application.
"""
object_id = album_id or "me"
#it would have been nice to reuse self.request; but multipart is messy in urllib
print image_path
post_args = {
'access_token': self.access_token,
'source': open(str(image_path), 'r'),
'source': image,
'message': message
}
post_args.update(kwargs)
Expand Down

0 comments on commit 67201e9

Please sign in to comment.