正在将Byte[]转换为流文件asp.net



我需要将Byte((转换为流,然后刷新它在asp.net应用程序中

这是我的代码:

Dim fileBytes As Byte() = Nothing
....
apiProp.BodyRequest = New JavaScriptSerializer().Serialize(entFile)
apiProp.EndPoint = "example.com/DownloadFile"
apiProp = api.MessageInvoke(apiProp)
entResponse = JsonConvert.DeserializeObject(Of FileResponse)(apiProp.BodyResponse)
fileBytes = Convert.FromBase64String(entFile.fileContent)

我试过了:

Response.BinaryWrite(fileBytes)
Response.Flush()

我尝试过任何文件流、内存流等。文件要求下载,但如果我下载文件,文件就会损坏

我需要将文件转换为流,因为我必须在图像文件上添加水印。我使用groupdocs.watermark添加水印。

using (Stream InputStream = fl.PostedFile.InputStream)
{
Object o = new object();
lock (o)
{
byte[] buffer = new byte[InputStream.Length];
InputStream.Read(buffer, 0, (int)InputStream.Length);
lock (o)
{
File.WriteAllBytes(rpath, buffer);
buffer = null;
}
InputStream.Close();
}
}

最新更新