def _handle_put(gs_stub, filename, param_dict, headers, payload):
 token = _get_param('upload_id', param_dict)
 content_range = _ContentRange(headers)
 if (content_range.value and (not content_range.finished)):
  gs_stub.put_continue_creation(token, payload, (content_range.start, content_range.end))
  response_headers = {}
  response_status = 308
 elif (content_range.value and content_range.finished):
  gs_stub.put_continue_creation(token, payload, (content_range.start, content_range.end), last=True)
  filestat = gs_stub.head_object(filename)
  response_headers = {'content-length': filestat.st_size}
  response_status = 200
 elif (not payload):
  gs_stub.put_continue_creation(token, '', None, True)
  filestat = gs_stub.head_object(filename)
  response_headers = {'content-length': filestat.st_size}
  response_status = 200
 else:
  raise ValueError('Missing header content-range but has payload')
 return _FakeUrlFetchResult(response_status, response_headers, '')

def _handle_put ( gs_stub , filename , param_dict , headers , payload ) : token = _get_param ( 'upload_id' , param_dict ) content_range = _ContentRange ( headers ) if ( content_range . value and ( not content_range . finished ) ) : gs_stub . put_continue_creation ( token , payload , ( content_range . start , content_range . end ) ) response_headers = { } response_status = 308 elif ( content_range . value and content_range . finished ) : gs_stub . put_continue_creation ( token , payload , ( content_range . start , content_range . end ) , last = True ) filestat = gs_stub . head_object ( filename ) response_headers = { 'content-length' : filestat . st_size } response_status = 200 elif ( not payload ) : gs_stub . put_continue_creation ( token , '' , None , True ) filestat = gs_stub . head_object ( filename ) response_headers = { 'content-length' : filestat . st_size } response_status = 200 else : raise ValueError ( 'Missing header content-range but has payload' ) return _FakeUrlFetchResult ( response_status , response_headers , '' )
handle put that continues object creation .