aiogoogle icon indicating copy to clipboard operation
aiogoogle copied to clipboard

Updating google drive file contents yields corrupted file due to multipart

Open AdeelK93 opened this issue 1 year ago • 5 comments

Hello! Big fan of this library. Let's say I have a csv I'd like to update, and the new revision looks like this:

a,b
1,4
2,5
3,6

If I try to update an existing file's contents (such that I can retain revision history, rather than deleting+creating) like this:

req = drive.files.update(fileId=new_file_id, upload_file=data.read(), supportsAllDrives=True, fields=fields)

On Google Drive, I'll get a corrupted multipart file.

--3c76f6a5ff7d445f9320bfd7b5bdfaee
Content-Type: application/json
Content-Length: 4

null
--3c76f6a5ff7d445f9320bfd7b5bdfaee
Content-Type: text/csv

a,b
1,4
2,5
3,6

--3c76f6a5ff7d445f9320bfd7b5bdfaee--

But if after declaring the req (and before requesting) I disable multipart:

req.media_upload.multipart = False

The file updates fine! Is there a way this could be fixed more automatically in the library?

Also - disabling multipart does nothing to fix the issue for pipe_from uploads. You'll get an identically corrupted file regardless.

AdeelK93 avatar May 06 '23 15:05 AdeelK93