I want to store images in database for various users.Its just like famous blog app but instead of blogs i want to store images in database.How can i implement my idea?
Asked
Active
Viewed 783 times
0
-
Consider saving images as BLOBs in some storage service or cloud and store URL to that image in your database. – Maciej M Oct 10 '19 at 13:51
-
See this similar question: https://stackoverflow.com/questions/18747730/storing-images-in-db-using-django-models – Dev Catalin Oct 10 '19 at 13:53
-
One option is to upload them to an S3 bucket and store the URL in your database. Here is a tutorial for uploading images to S3 via django -> https://blog.theodo.com/2019/07/aws-s3-upload-django/ – kreld Oct 10 '19 at 13:53
-
1May I kindly suggest that storing large binary data in a relational database usually turns out to be a very bad idea in practice ? There's a reason why everyone (well, almost... some people never learn) stores files (images or whatever) on the filesystem and only stores metadata (starting with the file's path of course) in the database. – bruno desthuilliers Oct 10 '19 at 14:13
-
@brunodesthuilliers i have no problem to store the images in file system but i want to know the alternate way if the data(images) are large in number. – Ram Patil Oct 10 '19 at 16:31
-
@RamPatil what makes you think that storing images in the DB will help you deal with having a lot of images ? – bruno desthuilliers Oct 14 '19 at 13:50
-
@brunodesthuilliers the output of my project is to display the images which is uploaded by the specific user.I thought it would be best to store the images(or url) in db so if i want to click on user's profile it would display all the images he/she uploaded.(just like instagram) – Ram Patil Oct 17 '19 at 17:00
1 Answers
0
You can do one thing -> change the image into base64 string and save it to database than when you want that image convert it from base64 to normal format. and you can find multiple tutorial on internet how to change image to base64 in python. why i am suggesting this because i used it in an android app.

Sampat Sharma
- 71
- 1
- 3