I
I
IKorob2017-10-13 10:59:22
ASP.NET
IKorob, 2017-10-13 10:59:22

How to retrieve a file from a database?

Good time!
I am writing an ASP.NET MVC net461 project.
I save an arbitrary file (.doc, .xls, etc.) in the MSSQL database. I store it as byte[]. But I can’t understand how I can download this file from the link on the client side? How to convert a byte array to a file?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Fat Lorrie, 2017-10-13
@IKorob

He who has hands, google it!

public ActionResult Index()
{
    byte[] contents = GetPdfFileData();
    return File(contents, "application/pdf", "test.pdf");
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question