I am able to use apiclient.http.MediaFileUpload in combination with service.files().create() to upload files to my drive in Python. However, if the file I am trying to create is zero bytes I get a
HttpError 400 when requesting https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable&alt=json returned "Bad Request" response.
I can't find anything in the documentation (or anywhere on the web in general) that mentions zero byte file creation through the API. Am I missing something? I am able to drag the zero byte file into Google Drive through the webpage and it uploads ok.
Here is a stripped down chunk of my code:
mimeType = mime.from_file(filePath)
media = apiclient.http.MediaFileUpload(
filePath,
mimetype=mimeType,
chunksize=4194304,
resumable=True
)
bodyDict = {
'name': fileName,
'parents': [fileParentID]
}
request = service.files().create(
media_body=media,
body=bodyDict
)
status, response = request.next_chunk()
Thanks