Closed jsjiang closed 7 months ago
Related to ticket #99
Current workflow:
download_request
APIdownload_request
API creates a request to the download queuedownload_request
API returns user an URL pointing to the downloadable file (not yet created)Solution option 1 "store file on S3 and generated a URL for download" requires minimum code change and is a good candidate for the first round refactoring without changing queue services.
subtasks:
Investigate if the "Download report in CSV format" in the Dashboard page requires refactoring.
The "Download report in CSV format" link calls the "impl.ui_admin.csvStats" function which uses "io.String" and "django.http.HttpResponse". This workflow does not save file on local disk and does not require refactoring with S3 implementation.
f = io.StringIO()
w = csv.writer(f)
return impl.ui_common.csvResponse(f.getvalue(), fn)
def csvResponse(message, filename):
r = django.http.HttpResponse(message, content_type="text/csv")
r["Content-Disposition"] = 'attachment; filename="' + filename + '.csv"'
return r
Batch download API:
Batch download UI function:
Email notification after request has been submitted:
Thank you for using EZID to easily create and manage your identifiers. The batch download you requested is available at:
https://ezid-stg.cdlib.org/download/Cn8XypqbcfvFRHdr.csv.gz
The download will be deleted in 1 week.
Best,
EZID Team
This is an automated email. Please do not reply.
The downloadable file for example https://ezid-stg.cdlib.org/download/Cn8XypqbcfvFRHdr.csv.gz is managed by the web server which give public access to the downloaded file.
One of the S3 solution option is to create a new API which resolves this link to a presinged URL: https://ezid-stg.cdlib.org/download/Cn8XypqbcfvFRHdr.csv.gz =>Define a presigned URL to the file (Cn8XypqbcfvFRHdr.csv.gz) saved in S3 => return the url for user to download the file
Refactor batch download to avoid using local disk. Possible solutions:
Tasks