In my project I am using this code to insert image to database
private void pctbPicture_Click(object sender, EventArgs e)
{
using (OpenFileDialog openFileDialog1 = new OpenFileDialog())
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
var filename = openFileDialog1.FileName;
var file = File.ReadAllBytes(filename);
// request.Image is byte[]
request.Image = file;
Image image = Image.FromFile(filename);
pctbProizvod.Image = image;
}
}
}
In my database when i try to check value of Image it only says byte array
But when i get data from swagger api i can see huge string of letters and numbers as value of image.
Now i am making dataseding script with test data and i would like to insert data from that string of numbers and letters as byte array in database.
something like this pseudocode
Product pp=new Product(){Image = ConverToByteArray(string that represents byte aray From Swagger) };
any help is appreciated!!
Thanks for trying to help