diff --git a/BlazorInputFile/FileListEntryImpl.cs b/BlazorInputFile/FileListEntryImpl.cs index 4ec8883..49d669e 100644 --- a/BlazorInputFile/FileListEntryImpl.cs +++ b/BlazorInputFile/FileListEntryImpl.cs @@ -22,6 +22,7 @@ public class FileListEntryImpl : IFileListEntry public long Size { get; set; } public string Type { get; set; } + public string Url { get; set; } public Stream Data { diff --git a/BlazorInputFile/IFileListEntry.cs b/BlazorInputFile/IFileListEntry.cs index 9a6f5fc..c59038b 100644 --- a/BlazorInputFile/IFileListEntry.cs +++ b/BlazorInputFile/IFileListEntry.cs @@ -13,6 +13,8 @@ public interface IFileListEntry string Type { get; } + string Url { get; } + Stream Data { get; } event EventHandler OnDataRead; diff --git a/BlazorInputFile/wwwroot/inputfile.js b/BlazorInputFile/wwwroot/inputfile.js index 13e7ab3..25432cd 100644 --- a/BlazorInputFile/wwwroot/inputfile.js +++ b/BlazorInputFile/wwwroot/inputfile.js @@ -6,13 +6,16 @@ elem.addEventListener('change', function handleInputFileChange(event) { // Reduce to purely serializable data, plus build an index by ID elem._blazorFilesById = {}; + var fileList = Array.prototype.map.call(elem.files, function (file) { + var result = { id: ++nextFileId, lastModified: new Date(file.lastModified).toISOString(), name: file.name, size: file.size, - type: file.type + type: file.type, + url: window.URL.createObjectURL(file) }; elem._blazorFilesById[result.id] = result;