9 # If server and client run in same local directory,
10 # need a separate place to store the uploads.
13 except FileExistsError:
19 print("Waiting for a connection.....")
22 conn, addr = s.accept()
23 print("Got a connection from ", addr)
24 connbuf = buffer.Buffer(conn)
29 file_name = connbuf.get_utf8()
32 # file_name = os.path.join('uploads',file_name)
33 # print('file name: ', file_name)
35 file_size = int(connbuf.get_utf8())
36 print('file size: ', file_size )
38 with open("/tmp/"+file_name, 'wb') as f:
41 chunk_size = 4096 if remaining >= 4096 else remaining
42 chunk = connbuf.get_bytes(chunk_size)
45 remaining -= len(chunk)
47 print('File incomplete. Missing',remaining,'bytes.')
49 print('File received successfully.')
50 print('Connection closed.')