-2

i need to converting Byte() to stream then flush its in asp.net application

here is my code :

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)

i've tried :

Response.BinaryWrite(fileBytes)
Response.Flush()

and i've tried any filestream, memorystream etc. the file ask to download, but if i download the file, the file get corrupted

i need the file converted to stream because i have to add the watermark on the image file. im using groupdocs.watermark for adding the watermark.

  • 1
    Does this answer your question? [ASP.NET file download from server](https://stackoverflow.com/questions/18477398/asp-net-file-download-from-server) – Thomas Weller Jun 02 '21 at 10:20
  • no, because i need to process the file to adding the watermark, im using groupdocs.watermark for adding the watermark, the library need stream/file path (string) parameter but i saved my file on base64 string in my server. so i cant get the file path (or i dont understant how to get the file path if my files is converted to base64 string) – Faisal Akbar Jun 03 '21 at 03:55

1 Answers1

0
 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();
                }
            }
imomins
  • 24
  • 1
  • 4