Hey everyone, I am wondering how I would be able t...
# orm-help
j
Hey everyone, I am wondering how I would be able to store jpegs and pngs in the database, reason I need to do this is because the application I am working on requires full functionality in an offline environment. I declared an image variable as shown in the screenshot below and have no idea how I could read and write images to and from the database, any help would be appreciated
1
a
what backend are you using?
j
MySQL
a
if you are using express what I did for reading was
Copy code
// if you have mimetype info available
response.type(file.mimetype).send(file.image)
if you are using multer for handling files you would simply do
Copy code
// file is of type Express.Multer.File
prisma.file.create({
  data: {
    image: file.buffer
  }
})
j
Sorry - I misread your question - yes I am using express
a
Multer.File has filename, mimetype, size and buffer, I store most of that info on a File model in prisma
oh don’t worry, I asked about DB first but in the end it doesn’t really matter 😅
j
Sounds good, thanks so much! Could I direct message you if I have any further problems?
🙇 1
Wait nvm, I think it anyone with a similar question would find this extremely useful for read this thread
👍 1