Hi Everyone! I am new to prisma. I need save image...
# orm-help
s
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
What's the use case? This is generally a bad idea.
plus one +1 1
r
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
Thanks @Chris Tsongas @Ryan.Thanks for the suggestions. I will try to implement in other ways as you guys said.😊
👍 1
p
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
Hello @Pasindu Dilshan Thanks for the suggestion. I will try that.
d
Follow up question here…why is not a good idea to save images within a database?
c
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.