what filetypes are supported and how to implement in uploadthing nextjs?

i have the corets set up but was wondering how to allow either a pdf or a docx file upload
2 Replies
muadpn
muadpn10mo ago
use blob and check the file type? or use pdf end point or docx end point i guess.
Sturlen
Sturlen10mo ago
you can filter by file types in your FileRouter (or MIME types to be exact). this should only allow pdf and word files:
// src\app\api\uploadthing\core.ts
// FileRouter for your app, can contain multiple FileRoutes
export const ourFileRouter = {
// Define as many FileRoutes as you like, each with a unique routeSlug
imageUploader: f({
"application/msword": { maxFileSize: "4MB" },
"application/pdf": { maxFileSize: "4MB" },
})
// src\app\api\uploadthing\core.ts
// FileRouter for your app, can contain multiple FileRoutes
export const ourFileRouter = {
// Define as many FileRoutes as you like, each with a unique routeSlug
imageUploader: f({
"application/msword": { maxFileSize: "4MB" },
"application/pdf": { maxFileSize: "4MB" },
})
related uploadthing docs: https://docs.uploadthing.com/api-reference/server#route-config
Server – uploadthing
Docs for the best file uploader to date
Want results from more Discord servers?
Add your server