Kgram
TTCTheo's Typesafe Cult
•Created by Kgram on 9/15/2024 in #questions
HTML To .doc
Hey! I've added the below code to extract the html from a TipTap text editor and let the user generate/download a word .doc file. There isn't a whole lot of documentation on this type of code that i can find. Can anyone see any security issues with this or anything i should be aware of before giving users this functionality?
const handleDownloadClick = () => {
const htmlContent = editor.getHTML();
const header =
<html xmlns:o='urn:schemas-microsoft-com🏢office'
xmlns:w='urn:schemas-microsoft-com🏢word'
xmlns='http://www.w3.org/TR/REC-html40'>
<head>
<meta charset='utf-8'>
<title>Document</title>
<style>
body {
font-family: 'Calibri', sans-serif;
font-size: 11pt;
color: #000000;
}
h1, h2, h3 {
font-family: 'Calibri', sans-serif;
color: #000000;
}
</style>
</head>
<body>
;
const footer = </body></html>
;
const fullContent = header + htmlContent + footer;
const blob = new Blob([fullContent], {
type: "application/msword;charset=utf-8",
});
const link = document.createElement("a");
const url = URL.createObjectURL(blob);
link.href = url;
link.download = `fileName.doc';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
};5 replies
TTCTheo's Typesafe Cult
•Created by Kgram on 8/25/2024 in #questions
File Upload To AI Service
I’m building a next JS app written in JavaScript (I know, I know, I’m still learning).
I want to know if Uploadthing will suit my use case. I need to allow users to upload audio files (greater than the 4.5mb limit of Vercel) which will then be passed to an AI service for transcription.
Can I use upload thing in a purely JavaScript project?
Are the uploads client side? If so can I stop the sharing of the URL with the client/ delete it once the AI transcription is complete?
3 replies