#NEWLINE# def upload( self , filepath ) : #NEWLINE# #INDENT# 'Uploads file from filepath to Redmine and returns an assigned token' #NEWLINE# if ( ( self . ver is not None ) and ( LooseVersion ( str ( self . ver ) ) < LooseVersion ( '1.4.0' ) ) ) : #NEWLINE# #INDENT# raise VersionMismatchError ( 'File upload' ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# with open ( url , 'rb' ) as stream : #NEWLINE# #INDENT# url = '{0}{1}' . format ( self . url , '/uploads.json' ) #NEWLINE# response = self . request ( 'post' , url , data = stream , headers = { #NEWLINE# #INDENT# 'Content-Type' : 'application/octet-stream' , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# except IOError : #NEWLINE# #INDENT# raise NoFileError #NEWLINE# #UNINDENT# return response [ 'upload' ] [ 'token' ]