I'm using google contacts api (gdata) to set a contact's photo in google contacts.
I'm using fiddler and I see that the request is sent according to Google Contacts Examples but the photo downloaded back from google is always 96x96.
The code I'm using to update and download the photo is:
public void UpdateUserPhoto(Contact contact, Stream photo)
{
_contactsRequest.SetPhoto(contact, photo);
}
public static void DownloadPhoto(ContactsRequest cr, Contact contact)
{
if (contact.PhotoEtag == null)
return;
Stream photoStream = cr.Service.Query(contact.PhotoUri);
FileStream outStream = File.OpenWrite(string.Format(@"c:\friends\{0}.jpg",contact.Name.FullName));
byte[] buffer;
using (var memoryStream = new MemoryStream())
{
photoStream.CopyTo(memoryStream);
buffer = memoryStream.ToArray();
}
outStream.Write(buffer, 0, buffer.Length);
photoStream.Close();
outStream.Close();
}
I tried syncing the contacts to my phone and there too, the size was always limited to 96x96. Am I doing something wrong or does google not allow syncing more than 96x96? I can see many apps that do sync contacts with more than 96x96 then I guess it's possible, but what is the right way?
Edit
Here are the sync & retrieval of the photo as captured by fiddler:
Sync photo request:
PUT https://www.google.com/m8/feeds/photos/media/mymail@gmail.com/55f3484e8aaf1c82 HTTP/1.1
Etag: "SomeEtag"
If-Match: "SomeEtag."
Content-Type: image/jpg
User-Agent: G-GoogleContactsSync/GOAuth2RequestFactory-CS-Version=2.2.0.0
Authorization: Bearer myAuthorization
GData-Version: 3.0
Host: www.google.com
Content-Length: 34480
Sync photo response
HTTP/1.1 200 OK
Content-Type: application/atom+xml; charset=UTF-8; type=entry
GData-Version: 3.1
ETag: "KgxxHGIyfCt7I2BoA047FShUNFU3BWx8RDQ."
Date: Wed, 01 Oct 2014 20:13:06 GMT
Expires: Wed, 01 Oct 2014 20:13:06 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Alternate-Protocol: 443:quic,p=0.01
Content-Length: 694
(Here comes xml with Id, Updated, edited etc.)
Photo Request:
GET https://www.google.com/m8/feeds/photos/media/myMail@gmail.com/55f3484e8aaf1c82 HTTP/1.1
Content-Type: application/atom+xml; charset=UTF-8
User-Agent: G-GoogleContactsSync/GOAuth2RequestFactory-CS-Version=2.2.0.0
Authorization: Bearer myAuthorization
GData-Version: 3.0
Host: www.google.com
Photo Response:
HTTP/1.1 200 OK
Content-Type: image/jpeg
Expires: Wed, 01 Oct 2014 20:25:54 GMT
Date: Wed, 01 Oct 2014 20:25:54 GMT
Cache-Control: private, max-age=0, must-revalidate, no-transform
Vary: Accept, X-GData-Authorization, GData-Version
GData-Version: 3.1
ETag: "SomeEtag."
Transfer-Encoding: chunked
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Alternate-Protocol: 443:quic,p=0.01