Commit 61181bb8 authored by Suzhi Bi's avatar Suzhi Bi

Upload New File

parent decc4a55
Pipeline #64 canceled with stages
import socket
import os
import sys
import struct
addr = sys.argv[1]
img_name = sys.argv[2]
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect( (str(addr),8085) )
except socket.error as msg:
print(msg)
sys.exit(1)
while 1:
filepath = "result_" + str(addr) + "_" + str(img_name)
print(filepath)
if os.path.isfile(filepath):
fileinfo_size = struct.calcsize('128sq')
fhead = struct.pack('128sq', bytes(os.path.basename(filepath).encode('utf-8')),os.stat(filepath).st_size)
s.send(fhead)
print ('client filepath: {0}'.format(filepath))
fp = open(filepath, 'rb')
while 1:
data = fp.read(1024)
if not data:
print ('{0} file send over...'.format(filepath))
break
s.send(data)
s.close()
break
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment