diff --git a/LearningHub.Nhs.WebUI/Services/FileService.cs b/LearningHub.Nhs.WebUI/Services/FileService.cs index a55433c9f..e0d19d7f2 100644 --- a/LearningHub.Nhs.WebUI/Services/FileService.cs +++ b/LearningHub.Nhs.WebUI/Services/FileService.cs @@ -145,14 +145,26 @@ public async Task DownloadFileAsync(string filePath, strin try { - // Directly download the entire file as a stream - var response = await file.DownloadAsync(); - return new FileDownloadResponse + if (fileSize <= 900 * 1024 * 1024) { - Content = response.Value.Content, - ContentType = properties.Value.ContentType, - ContentLength = fileSize, - }; + // Directly download the entire file as a stream + var response = await file.DownloadAsync(); + return new FileDownloadResponse + { + Content = response.Value.Content, + ContentType = properties.Value.ContentType, + ContentLength = fileSize, + }; + } + else + { + return new FileDownloadResponse + { + Content = await file.OpenReadAsync(), + ContentType = properties.Value.ContentType, + ContentLength = fileSize, + }; + } } catch (Exception ex) {