#NEWLINE# def start_upload( self , request ) : #NEWLINE# #INDENT# 'Starts a new upload based on the specified CreateRequest.' #NEWLINE# mime_type = None #NEWLINE# gs_filename = request . filename ( ) #NEWLINE# ignored_parameters = [ gs . _CACHE_CONTROL_PARAMETER , gs . _CANNED_ACL_PARAMETER , gs . _CONTENT_DISPOSITION_PARAMETER , gs . _CONTENT_ENCODING_PARAMETER ] #NEWLINE# for param in request . parameters_list ( ) : #NEWLINE# #INDENT# name = param . name ( ) #NEWLINE# if ( name == gs . _MIME_TYPE_PARAMETER ) : #NEWLINE# #INDENT# mime_type = param . value ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( name in ignored_parameters ) or name . startswith ( gs . _USER_METADATA_PREFIX ) ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise_error ( file_service_pb . FileServiceErrors . INVALID_PARAMETER ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( not mime_type ) : #NEWLINE# #INDENT# raise_error ( file_service_pb . FileServiceErrors . INVALID_PARAMETER ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not gs_filename ) : #NEWLINE# #INDENT# raise_error ( file_service_pb . FileServiceErrors . INVALID_PARAMETER ) #NEWLINE# #UNINDENT# #UNINDENT# random_str = '' . join ( ( random . choice ( ( string . ascii_uppercase + string . digits ) ) for _ in range ( 64 ) ) ) #NEWLINE# writable_name = ( '%s%s' % ( _GS_UPLOAD_PREFIX , base64 . urlsafe_b64encode ( random_str ) ) ) #NEWLINE# self . uploads [ writable_name ] = self . _Upload ( StringIO . StringIO ( ) , mime_type , gs_filename ) #NEWLINE# self . sequence_keys [ writable_name ] = None #NEWLINE# datastore . Delete ( datastore . Key . from_path ( GS_INFO_KIND , blobstore . create_gs_key ( gs_filename ) , namespace = '' ) ) #NEWLINE# return writable_name