Closed IsmailM closed 3 years ago
At the moment, when trying to download a file from S3, it's simply a file that contains the presigned URL:
I think this can be fixed as follows (this needs testing):
Change the following:
https://github.com/phenopolis/phenopolis_browser/blob/5d87f8870e2d3b56a6ed68884fdfdf35c4e93a8f/views/upload.py#L72-L82
# S3 pre-signed url lasts for 5 mins... DOWNLOAD_SIGNED_URL_TIME = 300 @application.route("/download/<file_key>", methods=["GET"]) @requires_admin def download_file(): signed_url = s3_client.generate_presigned_url( "get_object", Params={"Bucket": "phenopolis-website-uploads", "Key": file_key}, ExpiresIn=DOWNLOAD_SIGNED_URL_TIME ) return redirect(signed_url, code = 302)
I also refactored the code from a POST to a GET and added the file_key to URL...
So on the frontend - simply call /download/<file_key> - you may have to open it this link in a new tab so it does not affect the current page you are on...
/download/<file_key>
At the moment, when trying to download a file from S3, it's simply a file that contains the presigned URL:
I think this can be fixed as follows (this needs testing):
Change the following:
https://github.com/phenopolis/phenopolis_browser/blob/5d87f8870e2d3b56a6ed68884fdfdf35c4e93a8f/views/upload.py#L72-L82
I also refactored the code from a POST to a GET and added the file_key to URL...
So on the frontend - simply call
/download/<file_key>
- you may have to open it this link in a new tab so it does not affect the current page you are on...