#NEWLINE# def upload_file( self , filename , contents = None ) : #NEWLINE# #INDENT# '\n        Upload single artifact\n\n        :type filename: str\n        :type contents: str\n        :raise IOError:\n        ' #NEWLINE# body = MultiPartForm ( ) #NEWLINE# if ( contents is None ) : #NEWLINE# #INDENT# body . add_file ( 'file' , filename ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# body . add_file_as_string ( 'file' , filename , contents ) #NEWLINE# #UNINDENT# url = ( self . address + '/api/latest/image/%s/files?signature=%s' ) #NEWLINE# url = ( url % ( self . active_session_id , self . data_signature ) ) #NEWLINE# hdr = { #NEWLINE# #INDENT# 'Content-Type' : body . get_content_type ( ) , #NEWLINE# #UNINDENT# } #NEWLINE# response = self . _request ( url , body . form_as_bytes ( ) , headers = hdr ) #NEWLINE# if ( not response [ 'result' ] ) : #NEWLINE# #INDENT# raise IOError ( ( 'Upload failed: %s' % url ) )