def put_object(url, token=None, container=None, name=None, contents=None, content_length=None, etag=None, chunk_size=None, content_type=None, headers=None, http_conn=None, proxy=None, query_string=None, response_dict=None, service_token=None):
 if http_conn:
  (parsed, conn) = http_conn
 else:
  (parsed, conn) = http_connection(url, proxy=proxy)
 path = parsed.path
 if container:
  path = ('%s/%s' % (path.rstrip('/'), quote(container)))
 if name:
  path = ('%s/%s' % (path.rstrip('/'), quote(name)))
 if query_string:
  path += ('?' + query_string)
 if headers:
  headers = dict(headers)
 else:
  headers = {}
 if token:
  headers['X-Auth-Token'] = token
 if service_token:
  headers['X-Service-Token'] = service_token
 if etag:
  headers['ETag'] = etag.strip('"')
 if (content_length is not None):
  headers['Content-Length'] = str(content_length)
 else:
  for (n, v) in headers.items():
   if (n.lower() == 'content-length'):
    content_length = int(v)
 if (content_type is not None):
  headers['Content-Type'] = content_type
 elif ('Content-Type' not in headers):
  headers['Content-Type'] = ''
 if (not contents):
  headers['Content-Length'] = '0'
 if isinstance(contents, (ReadableToIterable, LengthWrapper)):
  conn.putrequest(path, headers=headers, data=contents)
 elif hasattr(contents, 'read'):
  if (chunk_size is None):
   chunk_size = 65536
  if (content_length is None):
   data = ReadableToIterable(contents, chunk_size, md5=False)
  else:
   data = LengthWrapper(contents, content_length, md5=False)
  conn.putrequest(path, headers=headers, data=data)
 else:
  if (chunk_size is not None):
   warn_msg = ('%s object has no "read" method, ignoring chunk_size' % type(contents).__name__)
   warnings.warn(warn_msg, stacklevel=2)
  if (hasattr(contents, '__iter__') and (not isinstance(contents, (six.text_type, six.binary_type, list, tuple, dict)))):
   contents = iter_wrapper(contents)
  conn.request('PUT', path, contents, headers)
 resp = conn.getresponse()
 body = resp.read()
 http_log((('%s%s' % (url.replace(parsed.path, ''), path)), 'PUT'), {'headers': headers}, resp, body)
 store_response(resp, response_dict)
 if ((resp.status < 200) or (resp.status >= 300)):
  raise ClientException.from_response(resp, 'Object PUT failed', body)
 etag = resp.getheader('etag', '').strip('"')
 return etag

def put_object ( url , token = None , container = None , name = None , contents = None , content_length = None , etag = None , chunk_size = None , content_type = None , headers = None , http_conn = None , proxy = None , query_string = None , response_dict = None , service_token = None ) : if http_conn : ( parsed , conn ) = http_conn else : ( parsed , conn ) = http_connection ( url , proxy = proxy ) path = parsed . path if container : path = ( '%s/%s' % ( path . rstrip ( '/' ) , quote ( container ) ) ) if name : path = ( '%s/%s' % ( path . rstrip ( '/' ) , quote ( name ) ) ) if query_string : path += ( '?' + query_string ) if headers : headers = dict ( headers ) else : headers = { } if token : headers [ 'X-Auth-Token' ] = token if service_token : headers [ 'X-Service-Token' ] = service_token if etag : headers [ 'ETag' ] = etag . strip ( '"' ) if ( content_length is not None ) : headers [ 'Content-Length' ] = str ( content_length ) else : for ( n , v ) in headers . items ( ) : if ( n . lower ( ) == 'content-length' ) : content_length = int ( v ) if ( content_type is not None ) : headers [ 'Content-Type' ] = content_type elif ( 'Content-Type' not in headers ) : headers [ 'Content-Type' ] = '' if ( not contents ) : headers [ 'Content-Length' ] = '0' if isinstance ( contents , ( ReadableToIterable , LengthWrapper ) ) : conn . putrequest ( path , headers = headers , data = contents ) elif hasattr ( contents , 'read' ) : if ( chunk_size is None ) : chunk_size = 65536 if ( content_length is None ) : data = ReadableToIterable ( contents , chunk_size , md5 = False ) else : data = LengthWrapper ( contents , content_length , md5 = False ) conn . putrequest ( path , headers = headers , data = data ) else : if ( chunk_size is not None ) : warn_msg = ( '%s object has no "read" method, ignoring chunk_size' % type ( contents ) . __name__ ) warnings . warn ( warn_msg , stacklevel = 2 ) if ( hasattr ( contents , '__iter__' ) and ( not isinstance ( contents , ( six . text_type , six . binary_type , list , tuple , dict ) ) ) ) : contents = iter_wrapper ( contents ) conn . request ( 'PUT' , path , contents , headers ) resp = conn . getresponse ( ) body = resp . read ( ) http_log ( ( ( '%s%s' % ( url . replace ( parsed . path , '' ) , path ) ) , 'PUT' ) , { 'headers' : headers } , resp , body ) store_response ( resp , response_dict ) if ( ( resp . status < 200 ) or ( resp . status >= 300 ) ) : raise ClientException . from_response ( resp , 'Object PUT failed' , body ) etag = resp . getheader ( 'etag' , '' ) . strip ( '"' ) return etag
for usage with container sync .