test_upload.py delete lock Revision 343537383731 (Fri Jan 16 2009 at 13:37) - Diff Link to this snippet: https://friendpaste.com/28kxlg0FrjbOSTyDLFLbZb Embed: manni perldoc borland colorful default murphy trac fruity autumn bw emacs pastie friendly Show line numbers Wrap lines 1234567891011121314151617181920212223242526272829303132333435363738import httplibimport 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 contentwhile 1: binarydata = f.read(100000) if binarydata == '': break conn.send(binarydata)response = conn.getresponse()print response.read()