Spaces:
Running
Running
| """Storage interface for DocVault.""" | |
| from abc import ABC, abstractmethod | |
| from typing import Any, Dict, List, Optional | |
| class StorageInterface(ABC): | |
| """Contract implemented by the active storage backend.""" | |
| def create_folder(self, user_id: str, folder_path: str) -> Dict[str, Any]: | |
| pass | |
| def upload_file( | |
| self, user_id: str, folder_path: str, filename: str, file_obj: Any | |
| ) -> Dict[str, Any]: | |
| pass | |
| def delete_file(self, user_id: str, file_path: str) -> Dict[str, Any]: | |
| pass | |
| def rename_file( | |
| self, user_id: str, file_path: str, new_name: str | |
| ) -> Dict[str, Any]: | |
| pass | |
| def delete_folder(self, user_id: str, folder_path: str) -> Dict[str, Any]: | |
| pass | |
| def rename_folder( | |
| self, user_id: str, folder_path: str, new_name: str | |
| ) -> Dict[str, Any]: | |
| pass | |
| def download(self, user_id: str, file_path: str) -> Dict[str, Any]: | |
| pass | |
| def list(self, user_id: str, prefix: str = "") -> Dict[str, List[Dict[str, Any]]]: | |
| pass | |
| def exists(self, user_id: str, path: str) -> bool: | |
| pass | |
| def get_stats(self, user_id: str) -> Dict[str, Any]: | |
| pass | |
| def get_history(self, user_id: str, path: str) -> List[Dict[str, Any]]: | |
| pass | |
| def restore( | |
| self, user_id: str, path: str, revision: str, as_copy: bool = False | |
| ) -> Dict[str, Any]: | |
| pass | |
| def add_link( | |
| self, user_id: str, url: str, title: str, description: str = "" | |
| ) -> Dict[str, Any]: | |
| pass | |
| def get_links(self, user_id: str) -> Dict[str, Any]: | |
| pass | |
| def delete_link(self, user_id: str, link_id: str) -> Dict[str, Any]: | |
| pass | |
| def update_link( | |
| self, user_id: str, link_id: str, url: str = "", title: str = "", description: str = "" | |
| ) -> Dict[str, Any]: | |
| pass | |
| def standardize_file( | |
| self, | |
| name: str, | |
| path: str, | |
| size: int, | |
| created_at: str, | |
| storage_type: str, | |
| modified_at: Optional[str] = None, | |
| ) -> Dict[str, Any]: | |
| return { | |
| "name": name, | |
| "path": path, | |
| "size": size, | |
| "type": "file", | |
| "created_at": created_at, | |
| "modified_at": modified_at or created_at, | |
| "storage": storage_type, | |
| } | |
| def standardize_folder( | |
| self, name: str, path: str, created_at: str, storage_type: str | |
| ) -> Dict[str, Any]: | |
| return { | |
| "name": name, | |
| "path": path, | |
| "type": "folder", | |
| "created_at": created_at, | |
| "storage": storage_type, | |
| } | |