From 9999b2167ac1fd1e64653799da1db150fabf31ec Mon Sep 17 00:00:00 2001 From: lemii Date: Mon, 15 Mar 2021 11:42:15 +0100 Subject: [PATCH] explicitly set mime type for plain text --- src/controllers/ipfs.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/controllers/ipfs.ts b/src/controllers/ipfs.ts index 164c74d..c745be0 100644 --- a/src/controllers/ipfs.ts +++ b/src/controllers/ipfs.ts @@ -14,7 +14,11 @@ export const downloadFile = async (req: Request, res: Response): Promise = const data = await fetchIpfsAsset(node, cid); const type = await FileType.fromBuffer(data); - res.status(200).send(type ? data : data.toString()); + if (type) { + res.status(200).send(data); + } else { + res.set('Content-Type', 'text/plain').status(200).send(data.toString()); + } } } catch (err) { res.status(500).send('Could not download file');