Add file upload and download (zip for directories)

This commit is contained in:
sarah committed 2026-09-28 22:57:09 +02:00
1 parent 0d564982dc
commit da4e02472f
7 files changed
+383 -42

No files matched your search

+22
View File
@@ -124,6 +124,28 @@ def MoveEntry(RootName: str, SourceRelativePath: str, DestinationRelativePath: s
RenameDirectoryNote(DestinationPath, OldName)
def SaveUploadedFile(
RootName: str, DirectoryRelativePath: str, FileName: str, FileBytes: bytes
) -> str:
DirectoryPath = ResolvePath(RootName, DirectoryRelativePath)
if not DirectoryPath.is_dir():
raise NotADirectoryError(f"{DirectoryPath} is not a directory.")
SafeName = Path(FileName).name
if not SafeName or SafeName in (".", ".."):
raise ValueError("Invalid file name.")
TargetPath = DirectoryPath / SafeName
if TargetPath.exists():
raise FileExistsError(f"{SafeName} already exists.")
TargetPath.write_bytes(FileBytes)
return SafeName
def DeleteEntry(RootName: str, RelativePath: str) -> None:
EntryPath = ResolvePath(RootName, RelativePath)