Skip to content

Commit 55745d1

Browse files
author
Benjamin Perez
committed
added independen support for pdf files
1 parent a062e25 commit 55745d1

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/Preview/PreviewFileContent.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ const PreviewFile = ({
179179
onLoad={iframeLoaded}
180180
/>
181181
)}
182-
{objectType === "text" && (
182+
{objectType === "pdf" && (
183183
<Fragment>
184184
<PreviewPDF
185185
path={path}
@@ -206,7 +206,7 @@ const PreviewFile = ({
206206
objectType !== "video" &&
207207
objectType !== "audio" &&
208208
objectType !== "image" &&
209-
objectType !== "text" && (
209+
objectType !== "pdf" && (
210210
<div className={`iframeBase ${loading ? "iframeHidden" : ""}`}>
211211
<iframe
212212
src={path}
@@ -216,7 +216,6 @@ const PreviewFile = ({
216216
isFullscreen ? "fullHeight" : objectType
217217
}`}
218218
onLoad={iframeLoaded}
219-
sandbox={""}
220219
>
221220
File couldn't be loaded. Please try Download instead
222221
</iframe>

portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/utils.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class BrowserDownload {
191191
}
192192
}
193193

194-
export type AllowedPreviews = "image" | "text" | "audio" | "video" | "none";
194+
export type AllowedPreviews = "image" | "pdf" | "text" | "audio" | "video" | "none";
195195
export const contentTypePreview = (contentType: string): AllowedPreviews => {
196196
if (contentType) {
197197
const mimeObjectType = (contentType || "").toLowerCase();
@@ -231,7 +231,8 @@ export const extensionPreview = (fileName: string): AllowedPreviews => {
231231
"png",
232232
"heic",
233233
];
234-
const textExtensions = ["pdf"];
234+
const textExtensions = ["txt"];
235+
const pdfExtensions = ["pdf"];
235236
const audioExtensions = ["wav", "mp3", "alac", "aiff", "dsd", "pcm"];
236237
const videoExtensions = [
237238
"mp4",
@@ -258,6 +259,10 @@ export const extensionPreview = (fileName: string): AllowedPreviews => {
258259
return "image";
259260
}
260261

262+
if(pdfExtensions.includes(fileExtension)) {
263+
return "pdf";
264+
}
265+
261266
if (textExtensions.includes(fileExtension)) {
262267
return "text";
263268
}

0 commit comments

Comments
 (0)