mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Merge pull request #13789 from mvdbeek/fix_slow_downloads
[22.01] Fix slow download of large files
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
API operations on the contents of a history dataset.
|
||||
"""
|
||||
import logging
|
||||
from io import IOBase
|
||||
from typing import (
|
||||
Any,
|
||||
cast,
|
||||
@@ -248,7 +249,13 @@ class FastAPIDatasets:
|
||||
):
|
||||
"""Streams the preview contents of a dataset to be displayed in a browser."""
|
||||
extra_params = get_query_parameters_from_request_excluding(request, {"preview", "filename", "to_ext", "raw"})
|
||||
display_data, headers = self.service.display(trans, history_content_id, history_id, preview, filename, to_ext, raw, **extra_params)
|
||||
display_data, headers = self.service.display(
|
||||
trans, history_content_id, history_id, preview, filename, to_ext, raw, **extra_params
|
||||
)
|
||||
if isinstance(display_data, IOBase):
|
||||
file_name = getattr(display_data, "name", None)
|
||||
if file_name:
|
||||
return FileResponse(file_name, headers=headers)
|
||||
return StreamingResponse(display_data, headers=headers)
|
||||
|
||||
@router.get(
|
||||
|
||||
@@ -469,7 +469,9 @@ class FastAPIHistoryContents:
|
||||
while maintaining approximate collection structure.
|
||||
"""
|
||||
archive = self.service.get_dataset_collection_archive_for_download(trans, id)
|
||||
return StreamingResponse(archive.get_iterator(), headers=archive.get_headers())
|
||||
if archive.upstream_mod_zip:
|
||||
return StreamingResponse(archive.response(), headers=archive.get_headers())
|
||||
return StreamingResponse(archive.get_iterator(), headers=archive.get_headers(), media_type="application/zip")
|
||||
|
||||
@router.post(
|
||||
'/api/histories/{history_id}/contents/{type}s',
|
||||
|
||||
Reference in New Issue
Block a user