Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7535221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:15:24+00:00 2026-05-30T06:15:24+00:00

I am writing a small app on Google App Engine to update the pictures

  • 0

I am writing a small app on Google App Engine to update the pictures in our users profiles. It takes there username and an image and does a put to there profile, uploading the image. Here is what i have:

import atom.data
import gdata.data
import gdata.contacts.client
import gdata.contacts.data
import cgi
import wsgiref.handlers

from google.appengine.api import users
from google.appengine.ext import webapp

email = 'admin@domain.com'
password = 'password'
domain = 'domain.com'

gd_client = gdata.contacts.client.ContactsClient(domain=domain)
gd_client.ClientLogin(email, password, 'photoUpdate')


class PicPage(webapp.RequestHandler):
    def get(self):
        self.response.out.write("""<html><head><title>Sasaki Photo Uploader</title>
                                    <link type="text/css" rel="stylesheet" href="/stylesheets/form.css"></head>
                                    <body>
                                    <form action="/" enctype="multipart/form-data" method="post">
                                    <div><label>Person Name</label></div>
                                    <div><textarea name="name" rows="2" columns "60"></textarea></div>
                                    <div><label>Image</label></div>
                                    <div><input type="file" name="img"/></div>
                                    <div><input type="submit" value="Upload" /></div>
                                    </form>
                                    </body>
                                    </html>""")

    def post(self):
        person_name = self.request.get('name')
        img_img = self.request.get('img')
        profile_url = 'https://www.google.com/m8/feeds/photos/profile/domain.com/%s' % person_name
        media_object = img_img
        print(profile_url)
        profile = gd_client.GetProfile(profile_url)
        print(profile)
        gd_client.ChangePhoto(media_object, profile)
        self.redirect('/')

def main():
  application = webapp.WSGIApplication(
                                       [('/', PicPage)
                                        ],
                                       debug=True)

  wsgiref.handlers.CGIHandler().run(application)

if __name__=="__main__":
  main()

When I run this it returns the error:

 Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\webapp\_webapp25.py", line 703, in __call__
    handler.post(*groups)
  File "C:\GAE_Local_Files\picupload\sasakipic.py", line 40, in post
    profile = gd_client.GetProfile(profile_url)
  File "C:\GAE_Local_Files\picupload\gdata\contacts\client.py", line 375, in get_profile
    auth_token=auth_token, **kwargs)
  File "C:\GAE_Local_Files\picupload\gdata\client.py", line 652, in get_entry
    desired_class=desired_class, **kwargs)
  File "C:\GAE_Local_Files\picupload\gdata\client.py", line 278, in request
    version=get_xml_version(self.api_version))
  File "C:\GAE_Local_Files\picupload\atom\core.py", line 520, in parse
    tree = ElementTree.fromstring(xml_string)
  File "<string>", line 106, in XML
ParseError: not well-formed (invalid token): line 1, column 0

i am not sure if this is because I am passing the profile url off as a string or uploading the pic wrong. Any advice, much appreciated.

EDIT Added full stack trace

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T06:15:25+00:00Added an answer on May 30, 2026 at 6:15 am

    Well, the answer lies in the issue that I pointed out in my edit. That line:

    profile = gd_client.GetProfile(profile_url)
    

    Is trying to query the picture located in the profile, but if it doesn’t exist it breaks, so I edit the try statement to pass the profile url directly:

    try:
        gd_client.ChangePhoto(media_object, profile_url)
    

    It worked great. This is a great little tool to update picture using App Engine, and you don’t even have to upload it, just run it locally on a app engine test server. I want to try and add some functionality, like image cropping, or resizing before the upload, large images look fine on the contact profile page, but can get distorted in the chat image.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a Google App Engine database that once it goes live will probably
I'm currently writing a small app that takes data provided by an SQL stored
I'm writing a small Scala app that does the following: 1) Read XML/XHTML files
Writing a small app that ( among other things ) lets users upload a
I am writing a small app which I need to test with utf-8 characters
I'm writing a small app for my friend's business, and thought I'd take the
I am writing a small app to teach myself ASP.NET MVC, and one of
I'm writing a small app to do a little processing on some cells in
I am writing a small app to automatically connect my PC to the internet
I'm a total amateur writing a small App to track to changes in folders.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.