| | |
| | | if file.filename == '': |
| | | return JSONResponse(content={"error": "没有选择文件"}, status_code=400) |
| | | if file and allowed_file(file.filename): |
| | | filename = secure_filename(file.filename) |
| | | filename = file.filename |
| | | save_path = os.path.join(SOURCE_FILES_PATH, filename) |
| | | with open(save_path, 'wb') as buffer: |
| | | shutil.copyfileobj(file.file, buffer) |
| | | save_path_list.append(save_path) |
| | | else: |
| | | return JSONResponse(content={"error": "不允许的文件类型"}, status_code=400) |
| | | return JSONResponse(content={"code": 200, "msg": "", "data": {}}, status_code=200) |
| | | |
| | | return JSONResponse(content={"code": 200, "msg": "文件上传成功", "data": {"file_paths": save_path_list}}, |
| | | status_code=200) |
| | | |
| | | # ws://localhost:9201/api/document/ws/excel |
| | | @router.websocket("/ws/excel") |