I have a stream which contains signature image from my xamarin forms signature pad. I need to upload the image to server but I getting error:
FATAL UNHANDLED EXCEPTION: System.ObjectDisposedException: Cannot access a closed Stream
I am getting the exception in PostAsync line.
How can I access the stream?
public async void Upload(object sender, EventArgs e)
{
signimgurl = await signature.GetImageStreamAsync(SignatureImageFormat.Png);
image.HeightRequest = 250;
image.Source = ImageSource.FromStream(() =>
{
return signimgurl;
});
var _content = new MultipartFormDataContent();
_content.Add(new StreamContent(signimgurl),
"\"file\"",
$"\"{"testsign"}\"");
var _httpClient = new HttpClient();
var _uploadServiceBaseAdress = "http://myserver.rocket.com/api/Files/Upload";
var httpResponesMessage = await _httpClient.PostAsync(_uploadServiceBaseAdress, _content);
string _imgLocation = await httpResponesMessage.Content.ReadAsStringAsync();
}