Is it possible to upload a file to a database in Next.js?
In this article, we analyse how Documenso stores an uploaded file into its database by reviewing its source code. Where is this code that does this? You will find the below code snippet in a file named upload/put-file.ts.
At this point, I wanted to find out what is the data type of the column that stores this value. For that, we first need to find out how this returned object is processed further.
prisma.documentData hints that documentData is the schema you should be looking for. In the schema.prisma, you will find the below model defined for DocumentData.
model DocumentData { id String @id @default(cuid()) type DocumentDataType data String initialData String Document Document? Template Template?}
To conclude this investigation, I found that file is saved as a string after some operations defined above.
Hey, my name is Ramu Narasinga. I study large open-source projects and create content about their codebase architecture and best practices, sharing it through articles, videos.