Dear Techie,
I have an query from API's . I have an functionality to post an image and name , place in to the database. but i dont couldn't achieve in C# api .
if (!Request.Content.IsMimeMultipartContent())
{
return StatusCode(HttpStatusCode.UnsupportedMediaType);
}
var filesReadToProvider = await Request.Content.ReadAsMultipartAsync();
var jsonkey = await filesReadToProvider.Contents[0].ReadAsStringAsync();
var fileBytes = await filesReadToProvider.Contents[0].ReadAsByteArrayAsync();
var data = jsonkey + fileBytes;
return Ok(data);
Answers
At which step did you encounter a problem? Could you post more details about the issue?
How did you load the images? You could store the images to the database as a byte[].
Download the api to get the byte array and convert it to the ImageSource.
if (!Request.Content.IsMimeMultipartContent())
{
return StatusCode(HttpStatusCode.UnsupportedMediaType);
}
var filesReadToProvider = await Request.Content.ReadAsMultipartAsync();
var jsonkey = await filesReadToProvider.Contents[0].ReadAsStringAsync();
var fileBytes = await filesReadToProvider.Contents[0].ReadAsByteArrayAsync();
var data = jsonkey + fileBytes;
return Ok(data);
What's wrong with the code? Please post details about that.
Breakpoint is not hitting var jsonkey . and when readAsMultipartAsync () its showing error
The breakpoint cannot be hit because of an error in 'readAsMultipartAsync'. What error occured? Please post the error log.