pydrive: RedirectMissingLocation: Redirected but the response is missing a Location: header

Viewed 3381

I need to override an existing file inside a google drive folder with a new file. This is what I have.

file = drive.CreateFile({'id': <id_of_file_which_I_wish_to_overwrite>})
file.SetContentFile(<my_file_path>)
file.Upload()
print('title: %s, mimeType: %s' % (file5['title'], file5['mimeType']))

I keep getting an error from file.Upload() line such as this:

RedirectMissingLocation: Redirected but the response is missing a Location: header.

Any ideas of what's causing this? What this Location is or the header? I noticed that I am not getting this error when I run the same code without file.SetContentFile and instead only change file metadata instead of overwriting it.

2 Answers

You know, PyDrive is a wrapper library of google-api-python-client.

According to this issue, there is some problem between google-api-python-client and httplib2.

So try installing a 0.15.0 version of httplib2. pip install httplib2==0.15.0

You should take a look at the size of the file that is being uploaded on Google Drive since you are getting the RedirectMissingLocation error.

Running the code above works for a much much smaller subset of that same data on the file.

Related