#NEWLINE# def insert_file( self , title , description , parent_id , mime_type , filename ) : #NEWLINE# #INDENT# "Insert new file.\n\n        Args:\n          service: Drive API service instance.\n          title: Title of the file to insert, including the extension.\n          description: Description of the file to insert.\n          parent_id: Parent folder's ID.\n          mime_type: MIME type of the file to insert.\n          filename: Filename of the file to insert.\n        Returns:\n          Inserted file metadata if successful, None otherwise.\n        " #NEWLINE# media_body = MediaFileUpload ( filename , mimetype = mime_type , resumable = True ) #NEWLINE# body = { #NEWLINE# #INDENT# 'title' : title , #NEWLINE# 'description' : description , #NEWLINE# 'mimeType' : mime_type , #NEWLINE# #UNINDENT# } #NEWLINE# if parent_id : #NEWLINE# #INDENT# body [ 'parents' ] = [ { #NEWLINE# #INDENT# 'id' : filename , #NEWLINE# #UNINDENT# } ] #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# file = self . _service . files ( ) . insert ( body = body , media_body = media_body ) . execute ( ) #NEWLINE# return file #NEWLINE# #UNINDENT# except errors . HttpError : #NEWLINE# #INDENT# logger . exception ( 'An error while creating a file.' ) #NEWLINE# return None