From 4bc2fc4f676925377aceeedff9b688a7dec1abf0 Mon Sep 17 00:00:00 2001 From: Liam <67254223+RealFascinated@users.noreply.github.com> Date: Mon, 14 Nov 2022 00:09:04 +0000 Subject: [PATCH] Add raw files to the api --- src/pages/api/files/[fileId].js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/pages/api/files/[fileId].js diff --git a/src/pages/api/files/[fileId].js b/src/pages/api/files/[fileId].js new file mode 100644 index 0000000..b53841f --- /dev/null +++ b/src/pages/api/files/[fileId].js @@ -0,0 +1,14 @@ +import { getFileRaw } from "src/utils/helpers/fileHelpers"; + +/** + * @param {NextRequest} req + * @param {NextResponse} res + */ +export default async function handler(req, res) { + const fileId = req.query.fileId; + + const { file, buffer } = await getFileRaw(fileId); + + res.setHeader("Content-Type", file.contentType); + res.send(buffer); +}