Skip to content

Commit

Permalink
HTML Presigned URL Component Proposal (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
williamputraintan authored Mar 6, 2023
1 parent 16d8409 commit eb67b96
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/components/ViewPresignedUrl/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,18 @@ export default function ViewPresignedUrl({ presingedUrl }: Props) {
}

// Return HTML (via iframe) display
if (HTML_FILETYPE_LIST.includes(filetype)) {

/** **************************** TEMPORARY SOLUTION ****************************
*
* Only allow S3 presigned url that is allowed to be viewed in this <iframe/> tag.
*
* See below 'TEMPORARY SOLUTION' block for details. Change to original solution if the fix has been made.
*
* Current solution: if (HTML_FILETYPE_LIST.includes(filetype) && presingedUrl.startsWith('https://umccr')) {
* Original solution: if (HTML_FILETYPE_LIST.includes(filetype)) {
*
* */
if (HTML_FILETYPE_LIST.includes(filetype) && presingedUrl.startsWith('https://umccr')) {
return (
<div className='w-full h-full'>
<iframe className='w-full h-full bg-white' src={presingedUrl} />
Expand Down Expand Up @@ -98,6 +109,26 @@ export default function ViewPresignedUrl({ presingedUrl }: Props) {
return <CircularLoaderWithText text='Fetching Content' />;
}

/** **************************** TEMPORARY SOLUTION ****************************
*
* This is specific to GDS data as `Content-Type` might be incorrect on GDS presigned URL. This causes
* iframe to download file instead of showing it. This is just a work around to download the content
* and show with srcDoc in iframe.
*
* This is a temporary solution. Remove this block when permanent solution is in place.
*
* Ref: https://umccr.slack.com/archives/CP356DDCH/p1677563982961669?thread_ts=1677476635.509959&cid=CP356DDCH
* */

if (HTML_FILETYPE_LIST.includes(filetype) && presingedUrl.startsWith('https://stratus-gds')) {
return (
<div className='w-full h-full'>
<iframe className='w-full h-full bg-white' srcDoc={data} />
</div>
);
}
/** ************************* END TEMPORARY SOLUTION BLOCK ********************** */

// Return JSON
if (filetype == 'json') {
// Sanitize if JSON is
Expand Down

0 comments on commit eb67b96

Please sign in to comment.