Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

91
Vistas
Streaming a file from Controller to View for user to download

I am looking to Stream a file from an internally generated URL(i.e http://192.168.x.x/download/filekeylink) to a user to download. The way I have it set up is the user hits the download button which sends a WEBAPI POST request to the controller which then hits an API that gets the URL with the file ready. The problem here is while I have experience loading local files from paths, I haven't ever streamed a file from a URL before and I was told this is possibly better than storing it in memory(can't store it locally)

js

async downloadAttach(ID: any) {
    
    window.open(await ApiFunc.post('Ticket', 'Download', CommID));// my own API call fucntion that works. 

    
}

Controller

[Route("api/Ticket/Download")]
        [HttpPost]
        public async Task<//Streamed file> Download([FromBody]string uri)
        {
            //Returning the streamed file to user to download
        }

What is the best practice around this(avoiding storing file locally or storing it in memory first). I have seen some people using

HttpWebRequest

However I am unsure that fits my needs as it seems this utilises the need to access the internal url(I could be wrong but when I tried it, it failed.)

For example this code here by Dallas:

Download/Stream file from URL - asp.net

I'm trying to understand how this would return to the client view and start the download in their browser without a return value. Is it because instead it would be using a GET API?

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda