3

How can I insert an image data in MySQL Database and then retrieve it using Golang?

Basically I want that task for upload profile picture of user in web application. According to the my knowledge,the best solution is save image as blob object in database.Is it best solution for upload image in webapplication in golang.?

Please help me find the best solution for that.I want to find the solution in golang.I am beginner for golang programming.

Sandun Priyanka
  • 591
  • 7
  • 24
  • 1
    consider yourself lucky that you don't know how to do this. Images shouldn't be saved in the database – e4c5 Aug 01 '16 at 08:59
  • @e4c5 why shouldn't? In my case images are thumbnails and doesn't expect much of space. – Sandun Priyanka Aug 01 '16 at 09:05
  • 1
    By saving images in the database (especially relation databases, like MySQL) you will eventually clog the pipeline with data that could reside elsewhere. It's probably faster to upload the image to disk and then access it from there. – Widerberg Aug 01 '16 at 10:35
  • You could save it into db. There are pros and cons. https://stackoverflow.com/a/6472268/3650955 – ufukomer Mar 20 '19 at 22:08

1 Answers1

-1

converting image to a blob and save it in the database is a somewhat long process and it may cause issues sometimes. The easiest way is saving the image to a server (or a local directory) and saving the image path in the database. In that way we can access the image by using the image path in the database. This, will show how to save image path and access it and converting image to a blob and save it in the database.

Here

0example.com
  • 317
  • 2
  • 4