What is the best practice to upload file using multer and create a record in Prisma
Recently I have been obsessed with uploading files with trpc, I have files that I do not want to keep on the cloud server and I want to keep them locally. I've done the uploads with Multer, but how do I associate them to my Prisma, for example Patient table? What is the best practice for this situation?
11 Replies
I was wondering if I could do something like
const upload = trpc.file.upload.useMutation()
and then inside the function
await upload.mutateAsync(file)
One more question, should the File schema be associated with the User schema or the Post schema in file uploads?
Any idea?
trpc currently only supports json content type but we want to support other content types later
@julius maybe only file infos?
i.e. is it ok for me to just keep the file information and call them?
Not sure what you mean by that
Let me explain, I save my files to local via multer with next api, at the same time, I want to keep the file information in my database while saving and associate them with the user or the post.
Do you think this is the right approach?
i would recommend using something like S3. Moreover if you're hosting on vercel, using presigned url's to get aroud the 5mb max upload size.
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
The files to be uploaded contain high confidentiality, patient records etc. Also thanks for the info
So how do you associate uploaded files with users or posts?
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
@SpudMaster amazing, thank you for help