google-code-export / gdata-python-client

Automatically exported from code.google.com/p/gdata-python-client
1 stars 0 forks source link

Photo upload fails #424

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Initialized and not None entry.

self.gd_client.ChangePhoto('test.jpg', entry, content_type='image/jpeg')

What is the expected output? 

added photo to contact

What do you see instead?

  File "C:\Python26\lib\site-packages\gdata\contacts\service.py", line 231, in ChangePhoto
    url = contact_entry_or_url.GetPhotoEditLink().href
AttributeError: 'NoneType' object has no attribute 'href'

What version of the product are you using? gdata-2.0.11

Original issue reported on code.google.com by konrad.s...@gmail.com on 6 Aug 2010 at 9:18

GoogleCodeExporter commented 9 years ago
Sorry, forgot to mention it is in contacts service

Original comment by konrad.s...@gmail.com on 6 Aug 2010 at 9:20

GoogleCodeExporter commented 9 years ago
Hi
I also have this error. Problem derives from the fact that ChangePhoto searchs 
for the uri dedicated to the image editing (rel ...#edit-photo), that seems to 
be missing from link list of the entry.  This is true for the entry retrieved 
by GetContact call (maybe for CreateContact also, I didn't tested), but the 
same entry, accessed from iterating in a GetContactFeed, DOES contain that key, 
so ChangePhoto works. In my case this is a little frustrating, because I 
iterate over all my (locally managed) contacts, and for each resulting updated 
respect gmail, i have to:
1) GetContact (or CreateContact, as is the case)
2) UpdateContact
3) if it has a (local) photo to upload, i must also:
4) GetContactsFeed filtered to retrieve only that entry
5) ChangePhoto using this last entry
A little long, but works.

Original comment by fabio.ca...@gmail.com on 12 Aug 2010 at 10:25

GoogleCodeExporter commented 9 years ago
Glad you found a work around. Please raise the lack of the photo edit link on 
the Contacts API Forum so that the underlying API can be fixed:

 http://www.google.com/support/forum/p/apps-apis/label?lid=074a8d2b04c0b2a9

   Thanks,
   -joe

Original comment by joe.gregorio@gmail.com on 28 Sep 2010 at 3:24

GoogleCodeExporter commented 9 years ago
Hey, Can u write the code here which adds a photo to contact.

Original comment by pkrocks....@gmail.com on 10 Jun 2011 at 7:45

GoogleCodeExporter commented 9 years ago
Please read the documentation and sync with the project repository in order to 
get the latest fixes:
  http://code.google.com/apis/contacts/docs/3.0/developers_guide_python.html#adding_photo

Best,
Alain

Original comment by ala...@google.com on 10 Jun 2011 at 3:43

GoogleCodeExporter commented 9 years ago
I pulled the revision 7e8b0032f693 and ChangePhoto seems to work fine, AS LONG 
AS there are no photos attached to the contact already. If contact already has 
a photo, it fails. Attempting to use DeletePhoto method fails too. Here's what 
I did to get it to add/replace the photo regardless of existing one:

import atom
my_req = atom.http_core.HttpRequest()
my_req.headers['If-Match'] = '*'
gd_client.ChangePhoto(
  'thumbnail.jpg',
  contact_entry,
  content_type='image/jpeg',
  http_request=my_req
)

I think the addition of that header should be made into an optional argument of 
ChangePhoto for that specific purpose.

Original comment by mans...@oxplot.com on 28 Jul 2011 at 2:51

GoogleCodeExporter commented 9 years ago
Hello,

This issue has been fixed with revision 651133d1893a and should make it to the 
next release.

Best,
Alain

Original comment by ala...@google.com on 3 Aug 2011 at 3:24