|
@@ -148,21 +148,11 @@ namespace Hotline.Api.Controllers
|
|
[HttpGet("download-proxy")]
|
|
[HttpGet("download-proxy")]
|
|
public async Task<IActionResult> DownloadProxy([FromServices] IHttpClientFactory clientFactory, string path)
|
|
public async Task<IActionResult> DownloadProxy([FromServices] IHttpClientFactory clientFactory, string path)
|
|
{
|
|
{
|
|
- try
|
|
|
|
- {
|
|
|
|
- _logger.LogInformation($"request file path: {path}");
|
|
|
|
using var client = clientFactory.CreateClient();
|
|
using var client = clientFactory.CreateClient();
|
|
var responseMessage = await client.GetAsync(path, HttpContext.RequestAborted);
|
|
var responseMessage = await client.GetAsync(path, HttpContext.RequestAborted);
|
|
responseMessage.EnsureSuccessStatusCode();
|
|
responseMessage.EnsureSuccessStatusCode();
|
|
var stream = await responseMessage.Content.ReadAsStreamAsync(HttpContext.RequestAborted);
|
|
var stream = await responseMessage.Content.ReadAsStreamAsync(HttpContext.RequestAborted);
|
|
return File(stream, responseMessage?.Content?.Headers?.ContentType?.MediaType);
|
|
return File(stream, responseMessage?.Content?.Headers?.ContentType?.MediaType);
|
|
- }
|
|
|
|
- catch (Exception e)
|
|
|
|
- {
|
|
|
|
- Console.WriteLine(e);
|
|
|
|
- throw;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|