Hi Everyone!
I am new to prisma.
I need save image in Postgres. I am using Prisma with nestjs. Using Model Type 'Bytes'. How can I save the image. Any example to save image during prisma.modelname.create() would be welcome. Thanks in advance.
c
Chris Tsongas
06/15/2021, 11:02 PM
What's the use case? This is generally a bad idea.
plus one +1 1
r
Ryan
06/16/2021, 4:47 AM
Prisma doesn’t support saving blob’s at the moment and I would agree this isn’t where you would want to store images. Using something like S3 or Cloudinary is a better option and then storing the name of the file in the database.
👍 1
s
Subash Ganesh
06/16/2021, 5:48 AM
Thanks @Chris Tsongas@Ryan.Thanks for the suggestions. I will try to implement in other ways as you guys said.😊
👍 1
p
Pasindu Dilshan
06/16/2021, 5:55 AM
Like Chris said, saving images within database is not a good idea 😅. Use an object storage like minio or S3 to store images. Then save the reference path or object key within the database for access purpose.
👍 1
s
Subash Ganesh
06/16/2021, 12:23 PM
Hello @Pasindu Dilshan Thanks for the suggestion. I will try that.
d
Dimitri Borgers
05/27/2022, 4:41 AM
Follow up question here…why is not a good idea to save images within a database?
c
Chris Tsongas
05/31/2022, 11:30 PM
Image files can be huge and will bog down and fill up your database, it doesn't perform well or scale well at all not to mention database storage is much, much more expensive than object storage. Serving images through a CDN will be orders of magnitude faster and more reliable.