diff --git a/src/Blazor.FileReader/Blazor.FileReader.csproj b/src/Blazor.FileReader/Blazor.FileReader.csproj
index c898573..8c431a0 100644
--- a/src/Blazor.FileReader/Blazor.FileReader.csproj
+++ b/src/Blazor.FileReader/Blazor.FileReader.csproj
@@ -14,15 +14,15 @@
blazor blazor-component stream filestream file-stream read-file filereader
Debug;Release;Ghpages
Tewr.Blazor.FileReader
- net6 support
+ fixes a bug under net6 that would throw PlatformNotSupportedException
MIT
icon.png
3.0
Tewr.Blazor.FileReader
Tewr.Blazor.FileReader
- 3.3.0.21348
- 3.3.0.21348
- 3.3.0.21348
+ 3.3.1.21360
+ 3.3.1.21360
+ 3.3.1.21360
diff --git a/src/Blazor.FileReader/FileReaderJsInterop.InteropFileStream.cs b/src/Blazor.FileReader/FileReaderJsInterop.InteropFileStream.cs
index 58a3227..19521ae 100644
--- a/src/Blazor.FileReader/FileReaderJsInterop.InteropFileStream.cs
+++ b/src/Blazor.FileReader/FileReaderJsInterop.InteropFileStream.cs
@@ -55,6 +55,11 @@ public override void Flush()
public override async Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
{
ThrowIfDisposed();
+ if (Position >= length)
+ {
+ return 0;
+ }
+
var bytesRead = await fileReaderJsInterop.ReadFileAsync(fileRef, buffer, Position, offset, count, cancellationToken);
Position += bytesRead;
return bytesRead;
diff --git a/src/Blazor.FileReader/FileReaderJsInterop.cs b/src/Blazor.FileReader/FileReaderJsInterop.cs
index 8c88a86..50da194 100644
--- a/src/Blazor.FileReader/FileReaderJsInterop.cs
+++ b/src/Blazor.FileReader/FileReaderJsInterop.cs
@@ -45,10 +45,13 @@ internal void Initialize()
UnmarshalledRuntime = new JSUnmarshalledRuntime(CurrentJSRuntime);
}
#endif
+
+#if NET5 || NETSTANDARD20
if (UnmarshalledRuntime is null)
{
throw new PlatformNotSupportedException($"{nameof(_options.UseWasmSharedBuffer)}=true is not supported on this platform: Unable to acquire {nameof(IJSUnmarshalledRuntime)}.");
}
+#endif
}
}
diff --git a/src/Blazor.FileReader/Tewr.Blazor.FileReader.md b/src/Blazor.FileReader/Tewr.Blazor.FileReader.md
index a8e156f..df868f6 100644
--- a/src/Blazor.FileReader/Tewr.Blazor.FileReader.md
+++ b/src/Blazor.FileReader/Tewr.Blazor.FileReader.md
@@ -67,9 +67,13 @@
- [CreateMemoryStreamAsync()](#M-Tewr-Blazor-FileReader-IFileReference-CreateMemoryStreamAsync-System-Threading-CancellationToken- 'Tewr.Blazor.FileReader.IFileReference.CreateMemoryStreamAsync(System.Threading.CancellationToken)')
- [CreateMemoryStreamAsync()](#M-Tewr-Blazor-FileReader-IFileReference-CreateMemoryStreamAsync-System-Int32- 'Tewr.Blazor.FileReader.IFileReference.CreateMemoryStreamAsync(System.Int32)')
- [CreateMemoryStreamAsync()](#M-Tewr-Blazor-FileReader-IFileReference-CreateMemoryStreamAsync-System-Int32,System-Threading-CancellationToken- 'Tewr.Blazor.FileReader.IFileReference.CreateMemoryStreamAsync(System.Int32,System.Threading.CancellationToken)')
+ - [GetJSObjectReferenceAsync()](#M-Tewr-Blazor-FileReader-IFileReference-GetJSObjectReferenceAsync 'Tewr.Blazor.FileReader.IFileReference.GetJSObjectReferenceAsync')
+ - [GetObjectUrlAsync()](#M-Tewr-Blazor-FileReader-IFileReference-GetObjectUrlAsync 'Tewr.Blazor.FileReader.IFileReference.GetObjectUrlAsync')
- [OpenReadAsync()](#M-Tewr-Blazor-FileReader-IFileReference-OpenReadAsync 'Tewr.Blazor.FileReader.IFileReference.OpenReadAsync')
- [OpenReadBase64Async()](#M-Tewr-Blazor-FileReader-IFileReference-OpenReadBase64Async 'Tewr.Blazor.FileReader.IFileReference.OpenReadBase64Async')
- [ReadFileInfoAsync()](#M-Tewr-Blazor-FileReader-IFileReference-ReadFileInfoAsync 'Tewr.Blazor.FileReader.IFileReference.ReadFileInfoAsync')
+- [IObjectUrl](#T-Tewr-Blazor-FileReader-IObjectUrl 'Tewr.Blazor.FileReader.IObjectUrl')
+ - [Url](#P-Tewr-Blazor-FileReader-IObjectUrl-Url 'Tewr.Blazor.FileReader.IObjectUrl.Url')
- [PasteEventOptions](#T-Tewr-Blazor-FileReader-DropEvents-PasteEventOptions 'Tewr.Blazor.FileReader.DropEvents.PasteEventOptions')
- [Additive](#P-Tewr-Blazor-FileReader-DropEvents-PasteEventOptions-Additive 'Tewr.Blazor.FileReader.DropEvents.PasteEventOptions.Additive')
- [PlatformConfig](#T-Tewr-Blazor-FileReader-PlatformConfig 'Tewr.Blazor.FileReader.PlatformConfig')
@@ -775,6 +779,36 @@ The length of the resulting [MemoryStream](http://msdn.microsoft.com/query/dev14
A [MemoryStream](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.IO.MemoryStream 'System.IO.MemoryStream') representing the full file, with [Position](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.IO.MemoryStream.Position 'System.IO.MemoryStream.Position') set to 0.
+##### Parameters
+
+This method has no parameters.
+
+
+### GetJSObjectReferenceAsync() `method`
+
+##### Summary
+
+Returns the underlying file object as an [IJSObjectReference](#T-Microsoft-JSInterop-IJSObjectReference 'Microsoft.JSInterop.IJSObjectReference')
+
+##### Returns
+
+
+
+##### Parameters
+
+This method has no parameters.
+
+
+### GetObjectUrlAsync() `method`
+
+##### Summary
+
+Returns an object url for a file.
+
+##### Returns
+
+
+
##### Parameters
This method has no parameters.
@@ -824,6 +858,28 @@ An object containing the file metadata
This method has no parameters.
+
+## IObjectUrl `type`
+
+##### Namespace
+
+Tewr.Blazor.FileReader
+
+##### Summary
+
+Represents an object url for a file.
+
+##### Remarks
+
+https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL
+
+
+### Url `property`
+
+##### Summary
+
+Returns the Object Url.
+
## PasteEventOptions `type`
diff --git a/src/Blazor.FileReader/Tewr.Blazor.FileReader.xml b/src/Blazor.FileReader/Tewr.Blazor.FileReader.xml
index 52873bf..e86d784 100644
--- a/src/Blazor.FileReader/Tewr.Blazor.FileReader.xml
+++ b/src/Blazor.FileReader/Tewr.Blazor.FileReader.xml
@@ -224,6 +224,18 @@
Provides properties and instance methods for the reading file metadata and aids in the creation of Readonly Stream objects.
+
+
+ Returns the underlying file object as an
+
+
+
+
+
+ Returns an object url for a file.
+
+
+
Opens a read-only to read the file.
@@ -404,6 +416,17 @@
Should reference either an input element of type file or a drop target.
a new instance of
+
+
+ Represents an object url for a file.
+
+ https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL
+
+
+
+ Returns the Object Url.
+
+
Returns true if the application is running on WASM.
diff --git a/src/Demo/Net6/Blazor.FileReader.Wasm.Demo/Program.cs b/src/Demo/Net6/Blazor.FileReader.Wasm.Demo/Program.cs
index b359429..def53f9 100644
--- a/src/Demo/Net6/Blazor.FileReader.Wasm.Demo/Program.cs
+++ b/src/Demo/Net6/Blazor.FileReader.Wasm.Demo/Program.cs
@@ -8,6 +8,6 @@
builder.RootComponents.Add("head::after");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
-builder.Services.AddFileReaderService();
+builder.Services.AddFileReaderService(x => x.UseWasmSharedBuffer = true);
await builder.Build().RunAsync();