#NEWLINE# def put( self , content , basename = '' , bucket = DEFAULT_BUCKET ) : #NEWLINE# #INDENT# identifier = self . get_identifier ( basename ) #NEWLINE# path = self . get_path ( identifier , bucket ) #NEWLINE# dirpath = dirname ( path ) #NEWLINE# if ( not isdir ( dirpath ) ) : #NEWLINE# #INDENT# os . makedirs ( dirpath ) #NEWLINE# #UNINDENT# length = 0 #NEWLINE# digest = md5 ( ) #NEWLINE# with openfile ( path , 'xb' ) as fh : #NEWLINE# #INDENT# while True : #NEWLINE# #INDENT# chunk = content . read ( CHUNK_SIZE ) #NEWLINE# if ( not chunk ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# fh . write ( chunk ) #NEWLINE# length += len ( chunk ) #NEWLINE# digest . update ( chunk ) #NEWLINE# #UNINDENT# #UNINDENT# b64digest = base64 . b64encode ( digest . digest ( ) ) #NEWLINE# return BlobInfo ( basename , length , ( 'md5-' + b64digest ) )