403 Forbidden when uploading files (there is a quota loaded for this file, so you cannot upload it at this time)

We are trying to download all files from the drive account. The problem can be reproduced with the following code:

import requests

f = requests.get ('https://www.googleapis.com/drive/v2/files/%s'% file_id, params = {'access_token': access_token})
download_url = f.json () ['downloadUrl']
r = requests.get (download_url, params = {'access_token': access_token}, stream = True)
with open ('/ path / to / file', 'wb') as f:
  for chunk in r.iter_content (chunk_size = 1024): 
    if chunk:
      f.write (chunk)
      f.flush ()

The third line returns 403 Forbidden.

Here are some interesting points:

  • This only happens with large files with sizes ranging from GB. The smallest file that is covered is 6 GB, with most files being 100 GB in size.
  • We used the file resource download url returned by the API, but this also happens with the revision resource download url.
  • On retrying a few days later, some of the affected files were downloaded successfully, but others still had the same error.

edit: When trying to upload a file manually, the error "Upload quota for this file, so you cannot upload it at this time" is displayed. Searching for this on Google doesn't show any useful results, so I still don't know how to proceed.

+3


source to share





All Articles