How to Return Files as Part of a JSON Response in ASP.NET Core API Securely?

Discussão em 'Angular' iniciado por fateme Eslamkhah, Dezembro 18, 2024.

  1. I am working on an ASP.NET Core web application that returns all results in JSON format. My frontend is built with Angular.

    I need to handle file downloads in my API, but I have some specific requirements:

    The files are sensitive and should not be accessible publicly via static file hosting. The API should restrict file access based on user permissions. Sometimes, I may need to return multiple files in a single API response. Files can be of any format, and I want the frontend (Angular) to handle their display or download based on access permissions. What is the best way to:

    Include file data (or links to files) in a JSON response while ensuring security? Handle multiple files in a response effectively? Avoid exposing static file URLs directly to users? I would appreciate any best practices or examples of how to achieve this in ASP.NET Core API.

    Continue reading...

Compartilhe esta Página