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 6635523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:03:56+00:00 2026-05-25T23:03:56+00:00

I developing an application which works with Google API, according to my understanding. def

  • 0

I developing an application which works with Google API, according to my understanding.

def push_to_ga(request):
    client = gdata.docs.service.DocsService()
    client.ClientLogin('account@gmail.com', 'password')

    entrys = Entry.objects.all()
    for entry in entrys:
        splitted = entry.file.split('/')
        client.UploadDocument(entry.file, splitted[-1])

    return HttpResponseRedirect('https://docs.google.com/#home')

Have an error:

Traceback:
File “/home/i159/Env/googleapi/lib/python2.6/site-packages/django/core/handlers/base.py” in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File “/home/i159/workspace/apiroot/googleapi/../googleapi/apiapp/views.py” in push_to_ga
38. client.UploadDocument(entry.file, ‘My entry #’ + str(entry.id))
File “/home/i159/Env/googleapi/lib/python2.6/site-packages/atom/init.py” in deprecated_function
1475. return f(*args, **kwargs)
File “/home/i159/Env/googleapi/lib/python2.6/site-packages/gdata/docs/service.py” in UploadDocument
494. folder_or_uri=folder_or_uri)
File “/home/i159/Env/googleapi/lib/python2.6/site-packages/gdata/docs/service.py” in _UploadFile
160. extra_headers={‘Slug’: media_source.file_name},

Exception Type: AttributeError at /push_to_ga/
Exception Value: ‘unicode’ object has no attribute ‘file_name’

I can’t find docs with description of the methods. How to upload file into Google Docs through API?

  • 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-25T23:03:57+00:00Added an answer on May 25, 2026 at 11:03 pm

    Which version of the Google API are you using?

    According to the Google documentation, for versions 1.0 and 2.0 you have to wrap the document as a MediaSource object in order to pass it to the Upload method. So, I think you need to replace:

    client.UploadDocument(entry.file, splitted[-1])
    

    with:

    ms = gdata.MediaSource(file_path=entry.file, content_type=gdata.docs.service.SUPPORTED_FILETYPES['DOC'])
    client.Upload(ms, splitted[-1])
    

    Note: this assumes that you are uploading Word files. You should set the content_type parameter to the correct type for each file that you upload.

    If you’re using version 3.0, you no longer need to create a MediaSource object – you can simply pass the pathname, title and mime type directly to the Upload method:

    client.Upload(entry.file, splitted[-1], content_type='application/msword')
    

    Uploading PDFs

    If you attempt to upload PDF files using version 2.0 of the API, it fails with the error:

    {'status': 415, 'body': 'Content-Type application/pdf is not a valid input type.', 'reason': 'Unsupported Media Type'}
    

    This can be fixed using the workaround shown in comment 77 on issue 591 on the Google Code site. Simple edit the _UploadFile method in your site-packages/gdata/docs/services.py file as shown on that ticket. Once you have made this change, PDF uploads should work fine (I have checked this & it works for me).

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

Sidebar

Related Questions

I'm developing an application which draws some charts and I'm using Google Chart. After
I am developing an iPhone application which works perfectly when doing a build &
I am developing an application which uses an xmlrpc service to communicate. I developed
I am developing web-application using Google Maps API and ASP.NET Ajax. Here is my
I am developing a Django application which works fine locally. In production, the application
I am developing an web application which can upload/download a file from client to
I'm developing a web application for a company which I work for. My team
When developing an application which mostly interacts with a database, what is a good
I am developing an application which will be connected to Access database at the
I'm developing an application which has a lot of text and also different modules

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.