You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
create an alternative SetContent to pass file descriptor. Check what is the best way to do this. Related, but not ready to merge - Update files.py googlearchive/PyDrive#166
The upload ownership and documentation work is complete on main for 2.0. SetContentFile(path) closes the file PyDrive2 opened after a successful upload or when its content is replaced. A failed upload keeps the handle open for a retry. If you abandon the retry, file.content.close() releases it immediately.
To upload a file object you already own, assign a seekable binary stream to file.content and call file.Upload() inside your own with block. The guide includes a working example, and the tests cover ownership, replacement, and retries. Closing as addressed by #410 and #418. Upload guide · Regression tests
Activity
shcheklein commentedon Nov 28, 2026
The upload ownership and documentation work is complete on
mainfor 2.0.SetContentFile(path)closes the file PyDrive2 opened after a successful upload or when its content is replaced. A failed upload keeps the handle open for a retry. If you abandon the retry,file.content.close()releases it immediately.To upload a file object you already own, assign a seekable binary stream to
file.contentand callfile.Upload()inside your ownwithblock. The guide includes a working example, and the tests cover ownership, replacement, and retries. Closing as addressed by #410 and #418. Upload guide · Regression tests