fix(file and app):

1. Handle the encoding issue when downloading Markdown files;
2. Experience the sharing of memory configuration
This commit is contained in:
Timebomb2018
2026-03-25 17:54:27 +08:00
parent def7367e33
commit caab58dd2f
7 changed files with 57 additions and 30 deletions

View File

@@ -325,27 +325,30 @@ class FileStorageService:
)
raise
async def get_file_url(self, file_key: str, expires: int = 3600) -> str:
async def get_file_url(
self,
file_key: str,
expires: int = 3600,
file_name: Optional[str] = None,
) -> str:
"""
Get an access URL for a file.
Args:
file_key: The file key.
expires: URL validity period in seconds (default: 1 hour).
file_name: If set, adds Content-Disposition: attachment to force download.
Returns:
URL for accessing the file.
"""
logger.debug(f"Getting file URL: file_key={file_key}, expires={expires}s")
try:
url = await self.storage.get_url(file_key, expires)
url = await self.storage.get_url(file_key, expires, file_name=file_name)
logger.debug(f"File URL generated: file_key={file_key}")
return url
except Exception as e:
logger.error(
f"Error getting file URL: file_key={file_key}, error={str(e)}"
)
logger.error(f"Error getting file URL: file_key={file_key}, error={str(e)}")
raise