Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BlazorInputFile/FileListEntryImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 2 additions & 0 deletions BlazorInputFile/IFileListEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public interface IFileListEntry

string Type { get; }

string Url { get; }

Stream Data { get; }

event EventHandler OnDataRead;
Expand Down
5 changes: 4 additions & 1 deletion BlazorInputFile/wwwroot/inputfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down