我正在尝试从我的 .net 核心 API 中的多部分表单/数据中获取图像,但我无法弄清楚正在使用什么编码来加密这些图像数据。基本上我需要得到这个字符串中表示的字节数组(图像的)
这就是我得到这个编码字符串的方式:
using (Stream responseStream = resposta.GetResponseStream())
{
var contentType = MediaTypeHeaderValue.Parse(response.ContentType);
var boundary = HeaderUtilities.RemoveQuotes(contentType.Boundary).Value;
for (MultipartReader smth = new(boundary, responseStream); ;)
{
try
{
MultipartSection section = await smth.ReadNextSectionAsync();
if (section == null)
break;
string contentTypeFrame = section.ContentType;
// Returns me the encoded string
string bodyValue = await section.ReadAsStringAsync();
if (bodyValue.ToLower().Contains("heartbeat"))
continue;
if (contentTypeFrame == "image/jpeg")
{
//Do something if it is an image
}
}
catch (Exception ex) { }
}
}
关于如何尝试解码此字符串以获取图像字节的任何想法?