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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:54:25+00:00 2026-06-07T11:54:25+00:00

I want to write a script to upload my photos to Google Drive. After

  • 0

I want to write a script to upload my photos to Google Drive. After couples of hours of digging into Google Document List API. I choose gdata-python-client 2.0.17(latest) to build my script. Everything works well, except that I cannot upload a file to a collection. Here is the exception.

Traceback (most recent call last):
  File "./upload.py", line 27, in 
    upload(sys.argv[1])
  File "./upload.py", line 22, in upload
    client.create_resource(p, collection=f, media=ms)
  File "/usr/local/lib/python2.7/dist-packages/gdata/docs/client.py", line 300, in create_resource
    return uploader.upload_file(create_uri, entry, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/gdata/client.py", line 1090, in upload_file
    start_byte, self.file_handle.read(self.chunk_size))
  File "/usr/local/lib/python2.7/dist-packages/gdata/client.py", line 1048, in upload_chunk
    raise error
gdata.client.RequestError: Server responded with: 400, <errors xmlns='http://schemas.google.com/g/2005'><error><domain>GData</domain><code>InvalidEntryException</code><internalReason>We're sorry, a server error occurred. Please try again.</internalReason></error></errors>

After hacking into the source code of gdata, I print some info for debugging.

>
Range: bytes 0-524287/729223
PUT TO: https://docs.google.com/feeds/upload/create-session/default/private/full/folder%3A0B96cfHivZx6ddGFwYXVCbzc4U3M/contents?upload_id=AEnB2UqnYRFTOyCCIGIESUIctWg6hvQIHY4JRMnL-CUQhHii3RGMFWZ12a7lXWd1hgOChd1Vqlr8d-BmvyfmhFhzhYK9Vnw4Xw
>
Range: bytes 524288-729222/729223
PUT TO: https://docs.google.com/feeds/upload/create-session/default/private/full/folder%3A0B96cfHivZx6ddGFwYXVCbzc4U3M/contents?upload_id=AEnB2UqnYRFTOyCCIGIESUIctWg6hvQIHY4JRMnL-CUQhHii3RGMFWZ12a7lXWd1hgOChd1Vqlr8d-BmvyfmhFhzhYK9Vnw4Xw

The exception raised when PUT the last part of file.

  • 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-06-07T11:54:28+00:00Added an answer on June 7, 2026 at 11:54 am

    I would advise you to try the new Google Drive API v2 that makes it much easier with better support for media upload: https://developers.google.com/drive/v2/reference/files/insert

    Once you get an authorized service instance, you can simply insert a new file like so:

    from apiclient import errors
    from apiclient.http import MediaFileUpload
    # ...
    
    def insert_file(service, title, description, parent_id, mime_type, filename):
      """Insert new file.
    
      Args:
        service: Drive API service instance.
        title: Title of the file to insert, including the extension.
        description: Description of the file to insert.
        parent_id: Parent folder's ID.
        mime_type: MIME type of the file to insert.
        filename: Filename of the file to insert.
      Returns:
        Inserted file metadata if successful, None otherwise.
      """
      media_body = MediaFileUpload(filename, mimetype=mime_type, resumable=True)
      body = {
        'title': title,
        'description': description,
        'mimeType': mime_type
      }
      # Set the parent folder.
      if parent_id:
        body['parents'] = [{'id': parent_id}]
    
      try:
        file = service.files().insert(
            body=body,
            media_body=media_body).execute()
    
        return file
      except errors.HttpError, error:
        print 'An error occured: %s' % error
        return None
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make an image upload API Example:http://mysite.com/api.php?url=http://test.com/1.jpg How to write a script
I want to write a script that loads a url (eg. http://google.com ) automatically.
i have a upload script that works with html5 file api and i want
I want to write a script that compares two directories. However, the file names
I want to write a script in AutoIt, which can take automatic input from
I want to write a script for gdb, which will save backtrace (stack) of
I want to write simple script to copy/backup directory then remove on server startup.
Basically I want to write a script to be able to detect when the
I am new to perforce, I want to write batch script for copying same
I want to write a batch script statement where: FINDSTR has to check for

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.