c# - [dotnet core MVC], I can't get file from byte array (field stored into database). -


i'm becoming crazy physical file database field. use asp.net mvc project (dotnet core 1.1). in avance , happy christams!

in part of controller :

public void download(int id) {     downloadmyfile(_context.mytable.find(id).myblobfield,                 _context.mytable.find(id).myfieldcontenttype,                  _context.richieste.find(id).myfieldoriginalfilename      );  }  public filecontentresult downloadmyfile(byte[] filebytes,                                    string filecontent, string filename) {             return file(filebytes, filecontent, filename); } 

my view :

<a asp-action="download" asp-route-id="@model.id"> download file</a> 

**

my notes:

if use this, works:

public fileresult download()         {             var filename = @"myrealfilenamestoredintheserver.ext";             var filepath = $"downloads/{filename}";             byte[] filebytes = system.io.file.readallbytes(filepath);             return file(filebytes, "application/x-msdownload", filename);         } 

but when pass byte array byte array doesn't work

i'm try using response method, can't find binarywrite() on aspnet core overloads of response... nothing using memorystream! can me please..?

read comment of stephen muecke understand has been issue.

 public filecontentresult download(int id)  {     return file(_context.mytable.find(id).myblobfield,                 _context.mytable.find(id).myfieldcontenttype,                  _context.richieste.find(id).myfieldoriginalfilename      );  } 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -