diff --git a/pydrive/files.py b/pydrive/files.py index 1d40304..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, filename): + def SetContentFile(self, filename, file = None): """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: