#NEWLINE# def CreateUploadSession( creation , success_path , user , max_bytes_per_blob , max_bytes_total , bucket_name = None ) : #NEWLINE# #INDENT# 'Create upload session in datastore.\n\n  Creates an upload session and puts it in Datastore to be referenced by\n  upload handler later.\n\n  Args:\n    creation: Creation timestamp.\n    success_path: Path in users application to call upon success.\n    user: User that initiated this upload, if any.\n    max_bytes_per_blob: Maximum number of bytes for any blob in the upload.\n    max_bytes_total: Maximum aggregate bytes for all blobs in the upload.\n    bucket_name: Name of the Google Storage bucket tio upload the files.\n\n  Returns:\n    String encoded key of new Datastore entity.\n  ' #NEWLINE# entity = datastore . Entity ( _UPLOAD_SESSION_KIND , namespace = '' ) #NEWLINE# entity_dict = { #NEWLINE# #INDENT# 'creation' : creation , #NEWLINE# 'success_path' : success_path , #NEWLINE# 'user' : user , #NEWLINE# 'state' : 'init' , #NEWLINE# 'max_bytes_per_blob' : max_bytes_per_blob , #NEWLINE# 'max_bytes_total' : max_bytes_total , #NEWLINE# #UNINDENT# } #NEWLINE# if success_path : #NEWLINE# #INDENT# entity_dict [ 'gs_bucket_name' ] = bucket_name #NEWLINE# #UNINDENT# entity . update ( entity_dict ) #NEWLINE# datastore . Put ( entity ) #NEWLINE# return str ( entity . key ( ) )