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.
-
2Your 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.– Justin HelgersonFeb 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.– Chris CalsoFeb 13, 2019 at 16:43
Add a comment
|
1 Answer
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.