I'm trying to write a small tool to upload Pictures from Google App Engine to Picasa. Fetching the image works, but when i try to upload it i get the error "TypeError: stat() argument 1 must be (encoded string without NULL bytes), not str"
The Code basically looks like this:
def getfile(url):
result = urlfetch.fetch(url)
if result.status_code == 200:
return (result.content)
logging.error ("[-] Error fetching URL: %s" % url)
def uploadpicture(comment,pic):
album_url = '/data/feed/api/user/%s/album/%s' % (username, album)
fname = "image.jpg"
entry = gd_client.InsertPhotoSimple(album_url, fname, comment, pic, content_type='image/jpeg')
picurl = "http://brilliantleap.com/blog/frog.jpg"
pic = getfile(picurl)
comment = "Test"
uploadpicture(comment, pic)
The full Stacktrace is:
Traceback (most recent call last):
File "/home/birt/stuff/google/appengine/ext/webapp/init.py", line 507, in call handler.get(*groups)
File "/home/birt/stuff/app_picasaupload/main.py", line 124, in get uploadpicture(comment, pic)
File "/home/birt/stuff/app_picasaupload/main.py", line 104, in uploadpicture entry = gd_client.InsertPhotoSimple(album_url, fname, comment, pic, content_type='image/jpeg')
File "/home/birt/stuff/app_picasaupload/gdata/photos/service.py", line 469, in InsertPhotoSimple content_type)
File "/home/birt/stuff/app_picasaupload/gdata/photos/service.py", line 398, in InsertPhoto os.path.exists(filename_or_handle): # it's a file name
File "/usr/lib/python2.5/posixpath.py", line 171, in exists st = os.stat(path)
File "/home/birt/stuff/google/appengine/tools/dev_appserver.py", line 1109, in call if not FakeFile.IsFileAccessible(path):
File "/home/birt/stuff/google/appengine/tools/dev_appserver.py", line 1018, in IsFileAccessible normcase=normcase)
File "/home/birt/stuff/google/appengine/tools/dev_appserver.py", line 1036, in _IsFileAccessibleNoCache if os.path.isdir(logical_filename):
File "/usr/lib/python2.5/posixpath.py", line 195, in isdir st = os.stat(path)
TypeError: stat() argument 1 must be (encoded string without NULL bytes), not str
Any Ideas ? :-)