下为组员3317的技术文档
项目二压缩相关的参考
项目二中压缩文件相关参考:
https://blog.csdn.net/weixin_42029733/article/details/86559612
https://www.cnblogs.com/gufengchen/archive/2019/05/31/10956009.html
程序中运用的代码主要参考了第一个链接中的
def zipDir(dirpath, outFullName):
'''
压缩指定文件夹
:param dirpath: 目标文件夹路径
:param outFullName: 压缩文件保存路径+XXXX.zip
:return: 无
'''
zip = zipfile.ZipFile(outFullName, 'w', zipfile.ZIP_DEFLATED)
for path, dirnames, filenames in os.walk(dirpath):
#去掉目标和路径,只对目标文件夹下边的文件及文件夹进行压缩(包括父文件夹本身)
this_path = os.path.abspath('.')
fpath = path.replace(this_path, '')
for filename in filenames:
zip.write(os.path.join(path, filename), os.path.join(fpath, filename))
zip.close()
其中把this_path = os.path.abspath('.')
一句删去,修改了下一句的参数。
下为组员3221的技术文档
header_struct=struct=struct.Struct('i1024s')
data_struct=struct.Struct('1024s')
传送的过程中采用了两种类型的数据结构
头部结构由1个整型和1024个char类型构成即总共1028个字节
数据结构由1024个char类型构成总共1024个字节
然后再传输一个文件的时候,首先把头部发送过去
header = {
'file_name': file_name,
'file_size': os.path.getsize(file_path