Выгрузка маршрутов: в имени файла сокращённые типы заявок (до 7) и дата
Имя формирует бэкенд и отдаёт в Content-Disposition (он добавлен в экспонируемые заголовки CORS), фронт сохраняет файл под этим именем. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -69,9 +69,9 @@ public sealed class ReportsController(VacancyReportService vacancies, RouteExpor
|
||||
var file = result.Value;
|
||||
|
||||
var disposition = new ContentDispositionHeaderValue("attachment");
|
||||
disposition.SetHttpFileName(RouteExportWorkbook.FileName);
|
||||
disposition.SetHttpFileName(file.FileName);
|
||||
Response.Headers.ContentDisposition = disposition.ToString();
|
||||
|
||||
return File(file, XlsxContentType);
|
||||
return File(file.Content, XlsxContentType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,10 @@ builder.Services.AddCors(options =>
|
||||
options.AddPolicy(CorsPolicyName, policy => policy
|
||||
.WithOrigins(corsAllowedOrigins)
|
||||
.AllowAnyHeader()
|
||||
.AllowAnyMethod());
|
||||
.AllowAnyMethod()
|
||||
// Без этого браузер не отдаёт скрипту Content-Disposition кросс-доменного ответа,
|
||||
// а из него фронт берёт имя скачиваемого файла (выгрузка маршрутов).
|
||||
.WithExposedHeaders("Content-Disposition"));
|
||||
});
|
||||
builder.Services.AddSingleton(TimeProvider.System);
|
||||
builder.Services.AddApprovalRouteInfrastructure(builder.Configuration);
|
||||
|
||||
Reference in New Issue
Block a user