#NEWLINE# def getChunkSize( self , chunk ) : #NEWLINE# #INDENT# '\n        Given a chunk that is either a file-like object or a string, attempt to\n        determine its length.  If it is a file-like object, then this relies on\n        being able to use fstat.\n\n        :param chunk: the chunk to get the size of\n        :type chunk: a file-like object or a string\n        :returns: the length of the chunk if known, or None.\n        ' #NEWLINE# if isinstance ( chunk , six . BytesIO ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if hasattr ( chunk , 'fileno' ) : #NEWLINE# #INDENT# return os . fstat ( chunk . fileno ( ) ) . st_size #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( chunk , six . text_type ) : #NEWLINE# #INDENT# return len ( chunk . encode ( 'utf8' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return len ( chunk )