mirror of
https://github.com/langgenius/dify.git
synced 2026-03-24 15:57:55 +08:00
fix: improve download filename handling in S3 storage and asset service
This commit is contained in:
@ -158,7 +158,9 @@ class SandboxFileArchiveSource(SandboxFileSource):
|
||||
except PipelineExecutionError as exc:
|
||||
raise RuntimeError(str(exc)) from exc
|
||||
|
||||
download_url = sandbox_storage.get_download_url(export_key, self._EXPORT_EXPIRES_IN_SECONDS)
|
||||
download_url = sandbox_storage.get_download_url(
|
||||
export_key, self._EXPORT_EXPIRES_IN_SECONDS, download_filename=filename
|
||||
)
|
||||
|
||||
return SandboxFileDownloadTicket(
|
||||
download_url=download_url,
|
||||
|
||||
@ -122,11 +122,10 @@ class AwsS3Storage(BaseStorage):
|
||||
downloads the file with this name instead of the S3 key.
|
||||
"""
|
||||
params: dict = {"Bucket": self.bucket_name, "Key": filename}
|
||||
if download_filename:
|
||||
# RFC 5987 / RFC 6266: Use both filename and filename* for compatibility.
|
||||
# filename* with UTF-8 encoding handles non-ASCII characters.
|
||||
encoded = quote(download_filename)
|
||||
params["ResponseContentDisposition"] = f"attachment; filename=\"{encoded}\"; filename*=UTF-8''{encoded}"
|
||||
# RFC 5987 / RFC 6266: Use both filename and filename* for compatibility.
|
||||
# filename* with UTF-8 encoding handles non-ASCII characters.
|
||||
encoded = quote(download_filename or filename)
|
||||
params["ResponseContentDisposition"] = f"attachment; filename=\"{encoded}\"; filename*=UTF-8''{encoded}"
|
||||
url: str = self.client.generate_presigned_url(
|
||||
ClientMethod="get_object",
|
||||
Params=params,
|
||||
|
||||
@ -363,9 +363,7 @@ class AppAssetService:
|
||||
) -> str:
|
||||
with Session(db.engine) as session:
|
||||
assets = AppAssetService.get_or_create_assets(session, app_model, account_id)
|
||||
tree = assets.asset_tree
|
||||
|
||||
node = tree.get(node_id)
|
||||
node = assets.asset_tree.get(node_id)
|
||||
if not node or node.node_type != AssetNodeType.FILE:
|
||||
raise AppAssetNodeNotFoundError(f"File node {node_id} not found")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user