Skip to content

Commit

Permalink
explicitly set mime type for plain text
Browse files Browse the repository at this point in the history
  • Loading branch information
lemii committed Mar 15, 2021
1 parent 43cd52c commit 9999b21
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/controllers/ipfs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ export const downloadFile = async (req: Request, res: Response): Promise<void> =
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');
Expand Down

0 comments on commit 9999b21

Please sign in to comment.