From aa8da099aab86dc177f60c436b5c53f45d2571fe Mon Sep 17 00:00:00 2001 From: Tarun Raghunandan Kaushik Date: Tue, 11 Jun 2019 20:18:41 +0530 Subject: [PATCH 1/2] Update files.py --- pydrive/files.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pydrive/files.py b/pydrive/files.py index 1d40304..97ff1ac 100644 --- a/pydrive/files.py +++ b/pydrive/files.py @@ -162,7 +162,7 @@ def SetContentString(self, content, encoding='utf-8'): if self.get('mimeType') is None: self['mimeType'] = 'text/plain' - def SetContentFile(self, filename): + def SetContentFile(self, file = None, filename): """Set content of this file from a file. Opens the file specified by this method. @@ -172,7 +172,11 @@ def SetContentFile(self, filename): :param filename: name of the file to be uploaded. :type filename: str. """ - self.content = open(filename, 'rb') + if(file is not None): + self.content = file + else: + self.content = open(filename, 'rb') + if self.get('title') is None: self['title'] = filename if self.get('mimeType') is None: From 922bac4197a3d9a95cd3c9c76d4c261809e56bcb Mon Sep 17 00:00:00 2001 From: Tarun Raghunandan Kaushik Date: Wed, 12 Jun 2019 20:09:01 +0530 Subject: [PATCH 2/2] Update files.py --- pydrive/files.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydrive/files.py b/pydrive/files.py index 97ff1ac..3d85428 100644 --- a/pydrive/files.py +++ b/pydrive/files.py @@ -162,7 +162,7 @@ def SetContentString(self, content, encoding='utf-8'): if self.get('mimeType') is None: self['mimeType'] = 'text/plain' - def SetContentFile(self, file = None, filename): + def SetContentFile(self, filename, file = None): """Set content of this file from a file. Opens the file specified by this method.