import httplib import os """ snippet to upload big files in couchdb. File test is created with dd: dd if=/dev/zero of=test4G bs=1024 count=4096000 """ headers={ 'Accept': 'application/json', 'Connection': 'keep-alive', 'Content-Type': 'application/octet-stream', 'Keep-Alive': '300', 'Content-Length': os.path.getsize('test4G')} f = open('test4G') conn = httplib.HTTPConnection('127.0.0.1:5984') conn.putrequest('PUT', '/test/blah/test4G?rev=516247523', skip_accept_encoding=True) # Send the HTTP headers. for header_name in headers: conn.putheader(header_name, headers[header_name]) conn.endheaders() # send content while 1: binarydata = f.read(100000) if binarydata == '': break conn.send(binarydata) response = conn.getresponse() print response.read()