Reputation: 402
I am creating one Google App Engine App in which I want to upload files to my Google Drive Folder.
For that I am using Google API Python Client Library. https://code.google.com/p/google-api-python-client/
I am using MediaIoBaseUpload function from library because I am getting file content from one Form. And I am using resumable upload.
When I am uploading a file of smaller size around 15 MB it works fine, but files which are larger than 15 MB I am getting error 400 Bad Request in last chunk.
All previous chunks works fine, but last chunk returns error.
I am trying to uploading one zip file(around 46 MB).
Here is my code:
fh = io.BytesIO(self.fileContent)
media = MediaIoBaseUpload(fh, "application/zip", 1024 * 1024, resumable=True)
http = httplib2.Http()
if credentials.invalid is True:
credentials.refresh(http)
else:
http = credentials.authorize(http)
drive_service = build('drive', 'v2', http=http)
body = {
'title': self.fileName,
'description': "",
"parents": [{
"kind": "drive#fileLink",
"id": self.folderId
}],
'mimeType': fileMimeType
}
response = drive_service.files().insert(body=body, media_body=media).execute()
Upvotes: 2
Views: 1026
Reputation: 9213
Don't set a kind
attribute for the parent. Use the following list instead:
"parents": [{ "id": self.folderId }]
Upvotes: 1