0

I am trying to automate my daily tasks using drive API and I came across an error when I try to upload the larger files (> 300 MB CSV) whereas the following code is working for uploading the smaller files (<100 MB). Added that I am running the snippet in my Debian Linux VM and no issues from my VM end.

from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
import os



gauth = GoogleAuth()
# Try to load saved client credentials if already done
gauth.LoadCredentialsFile("mycreds.txt")


drive_path = '<drive_id>'

data_to_be_uploaded = "my_big_file.csv"
    
# Declared the variable so that it will be uploaded as per the last date
file1 = drive.CreateFile({'title': my_big_csv_data+'.csv',
                          'parents': [{'id': drive_path}]
                          })
file1.SetContentFile(data_to_be_uploaded)
file1.Upload()

The error as following

  File "test_code.py", line 72, in <module>
    file1.Upload()
  File "/usr/share/hunch/lib/python3.6/site-packages/pydrive/files.py", line 285, in Upload
    self._FilesInsert(param=param)
  File "/usr/share/hunch/lib/python3.6/site-packages/pydrive/auth.py", line 75, in _decorated
    return decoratee(self, *args, **kwargs)
  File "/usr/share/hunch/lib/python3.6/site-packages/pydrive/files.py", line 369, in _FilesInsert
    http=self.http)
  File "/usr/share/hunch/lib/python3.6/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/share/hunch/lib/python3.6/site-packages/googleapiclient/http.py", line 810, in execute
    _, body = self.next_chunk(http=http, num_retries=num_retries)
  File "/usr/share/hunch/lib/python3.6/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/share/hunch/lib/python3.6/site-packages/googleapiclient/http.py", line 970, in next_chunk
    headers=headers)
  File "/usr/share/hunch/lib/python3.6/site-packages/oauth2client/transport.py", line 175, in new_request
    redirections, connection_type)
  File "/usr/share/hunch/lib/python3.6/site-packages/oauth2client/transport.py", line 282, in request
    connection_type=connection_type)
  File "/usr/share/hunch/lib/python3.6/site-packages/httplib2/__init__.py", line 1994, in request
    cachekey,
  File "/usr/share/hunch/lib/python3.6/site-packages/httplib2/__init__.py", line 1690, in _request
    content,
httplib2.RedirectMissingLocation: Redirected but the response is missing a Location: header.```

6
  • If the file size is an issue - why dont you try to compress the file? Commented Dec 6, 2020 at 13:34
  • @balderman: Tried that but the same error. Commented Dec 6, 2020 at 13:45
  • What is the file size after you compress it? Commented Dec 6, 2020 at 13:47
  • @balderman : It's around 50 MB. But still receiving error as httplib2.RedirectMissingLocation: Redirected but the response is missing a Location: header. Commented Dec 6, 2020 at 15:09
  • see stackoverflow.com/questions/59815620/… Commented Dec 6, 2020 at 15:15

2 Answers 2

1

Solved by downgrading my httplib2 package to 0.13.1

Reference used here

Thanks ! @balderman

Sign up to request clarification or add additional context in comments.

Comments

0

There are 100MB limits on some types of files

https://support.google.com/drive/answer/37603?hl=en

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.