0

I am adding an Image to MySQL database. My column type is LONGBLOB and i add it from .Net 6.0 project. My function is:

[HttpPost]
        public async Task<IActionResult> FotografEkle(string title, IFormFile image)
        {
            if(title == null || image == null)
            {
                return View();
            } else
            {
                using (var stream = new MemoryStream())
                {
                    await image.CopyToAsync(stream);
                    Resimler resim = new Resimler
                    {
                        Name = title,
                        Image = stream.ToArray(),
                        MimeType = image.ContentType
                    };
                    context.Resimlers.Add(resim);
                    await context.SaveChangesAsync();
                    return View();
                }
            }
        }

Type of Image is byte[]. The stream is not empty. It adds everything successfully to db but when i look at db my Image column, which is LONGBLOB one, is empty. What is the reason and solution?

aoiTenshi
  • 547
  • 1
  • 6
  • 20

0 Answers0