Skip to content
This repository has been archived by the owner on Jul 22, 2021. It is now read-only.

Update files.py #166

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pydrive/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
Expand Down