Currently, I am using PyDrive to upload my backup (.tar file) to google drive.
Is there a special thing to do with this library to upload a huge file to Google Drive (around 5gb). In the Google Drive API documentation, it says that we must use the Resumable upload ? https://developers.google.com/drive/web/manage-uploads
My problem is that when I try to send a huge file, the script executes without any errors, really quickly and the file does not appear in GoogleDrive. However, if I do this with a small file around 100mb, everything works perfectly fine...
My code is the following:
def upload(self, backupFile, backupFileName):
json_data=open(os.path.join(__location__, 'client_secrets.json'))
data = json.load(json_data)
"""Email of the Service Account"""
SERVICE_ACCOUNT_EMAIL = data['client_email']
"""Path to the Service Account's Private Key file"""
SERVICE_ACCOUNT_PKCS12_FILE_PATH = os.path.join(__location__, 'key.p12')
f = file(SERVICE_ACCOUNT_PKCS12_FILE_PATH, 'rb')
key = f.read()
f.close()
credentials = SignedJwtAssertionCredentials(SERVICE_ACCOUNT_EMAIL, key,
scope='https://www.googleapis.com/auth/drive', sub='email')
http = httplib2.Http()
credentials.authorize(http)
gauth = GoogleAuth()
gauth.credentials = credentials
drive = GoogleDrive(gauth)
file1 = drive.CreateFile({'title': backupFileName, "parents" : [{"id":"0B7FoN03AUUdZVlNETEtWLS1VTzQ"}]} ) # Create GoogleDriveFile instance with title 'Hello.txt'
file1.SetContentFile(backupFile);
file1.Upload()
When I try to send a large file, no errors are returned whatsoever. The python script simply ends without anything being shown...
There are 100MB limits on some types of files
https://support.google.com/drive/answer/37603?hl=en