From a961bfd1aa1abe0a60cf5721e493941dd8e4aac4 Mon Sep 17 00:00:00 2001 From: Peeyush Goyal Date: Mon, 24 May 2021 10:22:02 +0530 Subject: [PATCH 1/4] Added meta tag for Content-Security-Policy --- src/index.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/index.html b/src/index.html index 21df4cf32da..f71d36fcbd1 100644 --- a/src/index.html +++ b/src/index.html @@ -55,6 +55,10 @@ crossorigin="use-credentials" /> + From ee57328c2c7b318553f4d1e65c7169b00031b21f Mon Sep 17 00:00:00 2001 From: Peeyush Goyal Date: Mon, 24 May 2021 11:37:17 +0530 Subject: [PATCH 2/4] Meta Tag for Viewing Files --- src/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.html b/src/index.html index f71d36fcbd1..358162f07c1 100644 --- a/src/index.html +++ b/src/index.html @@ -57,7 +57,7 @@ From 987846777da75df3a326b6d88ae1444d40c3c3ac Mon Sep 17 00:00:00 2001 From: Peeyush Goyal Date: Mon, 24 May 2021 19:12:31 +0530 Subject: [PATCH 3/4] Download Button for downloading files issue #1182 --- src/Components/Patient/FileUpload.tsx | 58 +++++++++++++++++++++------ src/index.html | 4 +- 2 files changed, 47 insertions(+), 15 deletions(-) diff --git a/src/Components/Patient/FileUpload.tsx b/src/Components/Patient/FileUpload.tsx index 9943761fc12..5658bfa8ed7 100644 --- a/src/Components/Patient/FileUpload.tsx +++ b/src/Components/Patient/FileUpload.tsx @@ -36,6 +36,7 @@ import { VoiceRecorder } from "../../Utils/VoiceRecorder"; import { makeStyles, Theme, createStyles } from "@material-ui/core/styles"; import Modal from "@material-ui/core/Modal"; import { Close } from "@material-ui/icons"; +import { BrowserClient } from "@sentry/browser"; const Loading = loadable(() => import("../Common/Loading")); const PageTitle = loadable(() => import("../Common/PageTitle")); @@ -142,6 +143,7 @@ export const FileUpload = (props: FileUploadProps) => { const classes = useStyles(); const [modalStyle] = React.useState(getModalStyle); const [open, setOpen] = React.useState(false); + const [downloadURL, setDownloadURL] = useState(); const UPLOAD_HEADING: { [index: string]: string } = { PATIENT: "Upload Patient Files", @@ -157,6 +159,7 @@ export const FileUpload = (props: FileUploadProps) => { }; const handleClose = () => { + setDownloadURL(""); setOpen(false); }; @@ -222,6 +225,7 @@ export const FileUpload = (props: FileUploadProps) => { var data = { file_type: type, associating_id: getAssociatedId() }; var responseData = await dispatch(retrieveUpload(data, id)); // window.open(responseData.data.read_signed_url, "_blank"); + downloadFileUrl(responseData.data.read_signed_url); setFileUrl(responseData.data.read_signed_url); }; @@ -412,6 +416,15 @@ export const FileUpload = (props: FileUploadProps) => { }); }; + // For creating the Download File URL + const downloadFileUrl = (url: string) => { + fetch(url) + .then((res) => res.blob()) + .then((blob) => { + setDownloadURL(URL.createObjectURL(blob)); + }); + }; + return (
{ > {fileUrl && fileUrl.length > 0 ? ( <> -
- +
+ {downloadURL && downloadURL.length > 0 && ( + + )} + +
+ +