我试图将字节数组转换为c#中用于Web API的HttpPostedFileBase文件。但是转换后,我找不到文件名。
public class MemoryPostedFile : HttpPostedFileBase
{
private readonly byte[] fileBytes;
public MemoryPostedFile(byte[] fileBytes, string fileName = null)
{
this.fileBytes = fileBytes;
this.FileName = fileName;
this.InputStream = new MemoryStream(fileBytes);
}
public override int ContentLength => fileBytes.Length;
public override string FileName { get; }
public override Stream InputStream { get; }
}
HttpPostedFileBase objFile = (HttpPostedFileBase)new MemoryPostedFile(model.UserImage);