<s> """<STR_LIT>""" <EOL> from cloudstorage import api_utils , cloudstorage_api <EOL> import logging <EOL> import StringIO <EOL> import uuid <EOL> CLOUD_STORAGE_URL = '<STR_LIT>' <EOL> class CloudMemeStorage : <EOL> def uploadFile ( self , bucket , memeImage ) : <EOL> uniqueIdString = str ( uuid . uuid4 ( ) ) <EOL> uniqueIdString = uniqueIdString . replace ( '<STR_LIT:->' , '<STR_LIT>' ) <EOL> filename = bucket + '<STR_LIT>' + uniqueIdString + '<STR_LIT>' <EOL> url = CLOUD_STORAGE_URL + filename <EOL> write_retry_params = api_utils . RetryParams ( backoff_factor = <NUM_LIT> ) <EOL> cloud_file = cloudstorage_api . open ( filename , <EOL> '<STR_LIT:w>' , <EOL> content_type = '<STR_LIT>' , <EOL> options = { '<STR_LIT>' : '<STR_LIT>' } , <EOL> retry_params = write_retry_params ) <EOL> output = StringIO . StringIO ( ) <EOL> memeImage . save ( output , format = "<STR_LIT>" ) <EOL> contents = output . getvalue ( ) <EOL> output . close ( ) <EOL> try : <EOL> cloud_file . write ( contents ) <EOL> cloud_file . close ( ) <EOL> except Exception , e : <EOL> logging . error ( e ) <EOL> return Meme ( image_url = "<STR_LIT>" , text = "<STR_LIT>" ) <EOL> logging . info ( '<STR_LIT>' + filename ) <EOL> return url </s>
