diff --git a/frontend/src/components/share/FilePreview.tsx b/frontend/src/components/share/FilePreview.tsx index 789b8f2c..2b12dad6 100644 --- a/frontend/src/components/share/FilePreview.tsx +++ b/frontend/src/components/share/FilePreview.tsx @@ -2,6 +2,7 @@ import { Button, Center, Stack, Text, Title } from "@mantine/core"; import { modals } from "@mantine/modals"; import Link from "next/link"; import React, { Dispatch, SetStateAction, useEffect, useState } from "react"; +import api from "../../services/api.service"; const FilePreviewContext = React.createContext<{ shareId: string; @@ -58,7 +59,7 @@ const FileDecider = () => { return ; } else if (mimeType.startsWith("audio/")) { return ; - } else if (mimeType == "text/plain") { + } else if (mimeType.startsWith("text/")) { return ; } else { setIsNotSupported(true); @@ -115,15 +116,18 @@ const TextPreview = () => { const [text, setText] = useState(null); useEffect(() => { - fetch(`/api/shares/${shareId}/files/${fileId}?download=false`) - .then((res) => res.text()) - .then((text) => setText(text)); + api.get(`/shares/${shareId}/files/${fileId}?download=false`).then((res) => { + console.log(res.data); + setText(res.data); + }); }, [shareId, fileId]); return (
- {text} + + {text} +
); diff --git a/frontend/src/services/share.service.ts b/frontend/src/services/share.service.ts index 0e045a29..2d03bb13 100644 --- a/frontend/src/services/share.service.ts +++ b/frontend/src/services/share.service.ts @@ -61,7 +61,7 @@ const doesFileSupportPreview = (fileName: string) => { mimeType.startsWith("video/"), mimeType.startsWith("image/"), mimeType.startsWith("audio/"), - mimeType == "text/plain", + mimeType.startsWith("text/"), mimeType == "application/pdf", ];