feat(app-assets): add file download functionality with pre-signed URLs and enhance asset management

This commit is contained in:
Harry
2026-01-15 17:19:46 +08:00
parent 33f3374ea6
commit 6bb09dc58c
8 changed files with 296 additions and 47 deletions

View File

@ -38,3 +38,22 @@ class BaseStorage(ABC):
If a storage backend doesn't support scanning, it will raise NotImplementedError.
"""
raise NotImplementedError("This storage backend doesn't support scanning")
def get_download_url(self, filename: str, expires_in: int = 3600) -> str:
"""
Generate a pre-signed URL for downloading a file.
Storage backends that support pre-signed URLs (e.g., S3, Azure Blob, GCS)
should override this method to return a direct download URL.
Args:
filename: The file path/key in storage
expires_in: URL validity duration in seconds (default: 1 hour)
Returns:
Pre-signed URL string
Raises:
NotImplementedError: If this storage backend doesn't support pre-signed URLs
"""
raise NotImplementedError("This storage backend doesn't support pre-signed URLs")