MCPcopy Index your code
hub / github.com/vastsa/FileCodeBox / save_file

Method save_file

core/storage.py:121–131  ·  view source on GitHub ↗
(self, file: UploadFile, save_path: str)

Source from the content-addressed store, hash-verified

119 chunk = file.read(self.chunk_size)
120
121 async def save_file(self, file: UploadFile, save_path: str):
122 path_obj = Path(save_path)
123 directory = str(path_obj.parent)
124 # 提取原始文件名并进行清理
125 filename = await sanitize_filename(path_obj.name)
126 # 构建安全的完整保存路径
127 safe_save_path = self.root_path / directory / filename
128 # 确保目录存在
129 if not safe_save_path.parent.exists():
130 safe_save_path.parent.mkdir(parents=True)
131 await asyncio.to_thread(self._save, file.file, safe_save_path)
132
133 async def delete_file(self, file_code: FileCodes):
134 save_path = self.root_path / await file_code.get_file_path()

Callers

nothing calls this directly

Calls 2

sanitize_filenameFunction · 0.90
existsMethod · 0.80

Tested by

no test coverage detected