diff --git a/zt_backend/models/api/request.py b/zt_backend/models/api/request.py index 233538c2..eafbd2c3 100644 --- a/zt_backend/models/api/request.py +++ b/zt_backend/models/api/request.py @@ -174,6 +174,8 @@ class DeleteItemRequest(BaseModel): class FileWrite(BaseModel): path: str content: str + chunk_index: int + total_chunks: int class DownloadRequest(BaseModel): path: str diff --git a/zt_backend/router.py b/zt_backend/router.py index daa12f93..1bc08d48 100644 --- a/zt_backend/router.py +++ b/zt_backend/router.py @@ -765,7 +765,9 @@ def write_file(file_data: request.FileWrite): # Write the file try: - file_path.write_text(file_data.content, encoding='utf-8') + mode = "a" if file_data.chunk_index > 0 else "w" + with open(file_path, mode, encoding="utf-8") as f: + f.write(file_data.content) except IOError as e: raise HTTPException(status_code=500, detail=f"Failed to write file: {str(e)}") diff --git a/zt_frontend/src/components/FileEditorDialog.vue b/zt_frontend/src/components/FileEditorDialog.vue index 1a089918..0e626f00 100644 --- a/zt_frontend/src/components/FileEditorDialog.vue +++ b/zt_frontend/src/components/FileEditorDialog.vue @@ -63,7 +63,7 @@ -