0

How do I add a file attachment using .NET Core/Razor on my application to be able to read/download uploaded files? The Microsoft documentation on stream reader only gives me how to upload/delete the files, but not how to link it on html to be able to download/save/open the file.

2
  • 2
    Your question is a bit broad. What have you tried that isn't working? There are a number of ways to go about saving the file and then serving it up for people to download/save. As an example you could store the file content in a database, you could store it in a cloud storage service like S3, etc. Feb 13, 2019 at 16:24
  • I'm storing the files on my local SQL server database and need a way to add a link for users in my application to be able to download/save/open the file attachment. Most examples I found uses a directory which is something I don't want. I need a StreamReader of some sort. Feb 13, 2019 at 16:43

1 Answer 1

1

You said you're storing the data in a database. It sounds like you might want to leverage the FileContentResult class for this. You can give it a byte[] and a content type to serve up the file to your users.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.