我有一个包含来自我的xamarin表单签名板的签名图像的流。我需要将图像上传到服务器但我收到错误:
FATAL UNHANDLED EXCEPTION:System.ObjectDisposedException:不能 访问封闭的流
我在PostAsync行中收到异常。
如何访问流?
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();
}