Failed to update mimeType using Google Drive API

I have uploaded some files to Google Drive but have mistakenly assigned the wrong mimeType for some files. Now I want to change the mimeType value to be the correct value.

I have the following Python code that successfully updates the description associated with the file, but the mimeType always retains its original value.

file = service.files().get(fileId=GoogleFileId).execute()
file['mimeType'] = 'application/msword'
file['description'] = 'test description'
updated_file = service.files().update(fileId=file['id'], body=file, updateViewedDate=False).execute()

      

Can anyone spot what I'm missing?

Dave

+3


source to share


1 answer


Yes, you will need to update the contents of the file. The MimeType is calculated from the file that was loaded. Do this by passing media_body

, etc., which you used to create the file.



This is unpleasant to do, sorry. But if you script it, it should hurt you too much for "some files".

+2


source







All Articles