|
@@ -165,20 +165,9 @@ class VersionManagement(View):
|
|
|
full_name = upload_path + file_name
|
|
|
if os.path.exists(full_name): # 删除同名文件
|
|
|
os.remove(full_name)
|
|
|
- chunk_size = 1024 * 1024 * 4
|
|
|
- # 判断文件大小
|
|
|
- if fileSize < chunk_size:
|
|
|
- with open(full_name, 'wb+') as write_file:
|
|
|
- for chunk in file.chunks():
|
|
|
- write_file.write(chunk)
|
|
|
- # 分割上传文件进行上传
|
|
|
- else:
|
|
|
- with open(file_name, 'wb+') as write_file:
|
|
|
- num_chunks = math.ceil(fileSize / chunk_size)
|
|
|
- for chunk in range(num_chunks):
|
|
|
- chunk_file_path = os.path.join(upload_path, f'{chunk}.chunk')
|
|
|
- with open(chunk_file_path, 'wb') as chunk_file:
|
|
|
- chunk_file.write(write_file.read(5))
|
|
|
+ with open(full_name, 'wb+') as write_file:
|
|
|
+ for chunk in file.chunks():
|
|
|
+ write_file.write(chunk)
|
|
|
return response.json(0)
|
|
|
except Exception as e:
|
|
|
return response.json(500, repr(e))
|