diff --git a/src/Core/Components/InputFile/FluentInputFile.razor.cs b/src/Core/Components/InputFile/FluentInputFile.razor.cs index b1b34cd362..43a874455b 100644 --- a/src/Core/Components/InputFile/FluentInputFile.razor.cs +++ b/src/Core/Components/InputFile/FluentInputFile.razor.cs @@ -238,7 +238,6 @@ protected async Task OnUploadFilesHandlerAsync(InputFileChangeEventArgs e) foreach (IBrowserFile file in allFiles) { ProgressFileDetails = new ProgressFileDetails(fileNumber, file.Name, 0); - // Keep a trace of this file FluentInputFileEventArgs? fileDetails = new() { @@ -247,6 +246,7 @@ protected async Task OnUploadFilesHandlerAsync(InputFileChangeEventArgs e) Name = file.Name, ContentType = file.ContentType, Size = file.Size, + LastModified = file.LastModified, IsCancelled = false, }; uploadedFiles.Add(fileDetails); diff --git a/src/Core/Components/InputFile/FluentInputFileEventArgs.cs b/src/Core/Components/InputFile/FluentInputFileEventArgs.cs index 14b4c5105a..6188f32c57 100644 --- a/src/Core/Components/InputFile/FluentInputFileEventArgs.cs +++ b/src/Core/Components/InputFile/FluentInputFileEventArgs.cs @@ -42,6 +42,11 @@ public class FluentInputFileEventArgs : EventArgs /// public string ContentType { get; internal set; } = string.Empty; + /// + /// Gets the last modified date of the current file in an upload process. + /// + public DateTimeOffset LastModified { get; internal set; } = default!; + /// /// Gets the label to display in an upload process. /// diff --git a/tests/Core/InputFile/FluentInputFileTests.razor b/tests/Core/InputFile/FluentInputFileTests.razor index cd02672289..edbeab6855 100644 --- a/tests/Core/InputFile/FluentInputFileTests.razor +++ b/tests/Core/InputFile/FluentInputFileTests.razor @@ -187,4 +187,25 @@ Assert.False(fileUploaded, "OnFileUploaded"); Assert.False(progressChange, "OnProgressChange"); } + + [Fact] + public void FluentInputFile_LastModifiedDateSet() + { + var lastChanged = new DateTimeOffset(2024, 12, 14, 15, 30, 0, TimeSpan.Zero); + var fileToUpload = InputFileContent.CreateFromText("Text content", "Filename.txt", lastChanged); + bool lastModifiedSet = false; + + // Arrange + var cut = Render(@ + ); + + // Act + var inputFile = cut.FindComponent(); + inputFile.UploadFiles(fileToUpload); + + // Assert + Assert.True(lastModifiedSet, "LastModifiedSet"); + } }