Skip to content

Latest commit

 

History

History
971 lines (590 loc) · 42.2 KB

Tewr.Blazor.FileReader.md

File metadata and controls

971 lines (590 loc) · 42.2 KB

Tewr.Blazor.FileReader

Contents

AsyncDisposableStream type

Namespace

Tewr.Blazor.FileReader

Summary

Stream that implements IAsyncDisposable

DisposeAsync() method

Summary

Inherit from parent.

Parameters

This method has no parameters.

BrowserFileReaderException type

Namespace

Tewr.Blazor.FileReader

Summary

Exception that is thrown if an exception occurs in the browser during file reader operations

DropEffect type

Namespace

Tewr.Blazor.FileReader.DropEvents

Summary

Possible values of the DataTransfer.dropEffect property

Remarks

https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/dropEffect

Copy constants

Summary

A copy of the source item is made at the new location.

Link constants

Summary

A link is established to the source at the new location.

Move constants

Summary

An item is moved to a new location.

None constants

Summary

The item may not be dropped.

DropEventsOptions type

Namespace

Tewr.Blazor.FileReader.DropEvents

Additive property

Summary

If set to true, drop target file list becomes additive. Defaults to false.

OnDragOverMethod property

Summary

Predefined global javascript function that will be executed on the dragover event. The method will be passed the following arguments: The DragEvent, the target element, and the FileReaderComponent instance.

OnDragOverScript property

Summary

Javascript function snippet that will be executed on the dragover event. The method will be passed the following arguments: The DragEvent, the target element, and the FileReaderComponent instance. Do not set this property using user-provided data, as it would be a security risk.

OnDropMethod property

Summary

Predefined global javascript function that will be executed on the drop event. The method will be passed the following arguments: The Event, the target element, and the FileReaderComponent instance.

OnDropScript property

Summary

Javascript function snippet that will be executed on the drop event. The method will be passed the following arguments: The DragEvent, the target element, and the FileReaderComponent instance. Do not set this property using user-provided data, as it would be a security risk.

OnRegisterDropEventsMethod property

Summary

Predefined global javascript function that will be executed immediately after the drag and drop events have been registered. The method will be passed the following arguments: null, the target element, and the FileReaderComponent instance.

OnRegisterDropEventsScript property

Summary

Javascript function snippet that will be executed immediately after the drag and drop events have been registered. The method will be passed the following arguments: null, the target element, and the FileReaderComponent instance. Do not set this property using user-provided data, as it would be a security risk.

DropEventsOptionsExtensions type

Namespace

Tewr.Blazor.FileReader.DropEvents

SetDragOverDataTransferDropEffect(source,dropEffect) method

Summary

Sets the specified value on the dataTransfer property in the dragover event to the specified value.

Returns
Parameters
Name Type Description
source Tewr.Blazor.FileReader.DropEvents.DropEventsOptions
dropEffect Tewr.Blazor.FileReader.DropEvents.DropEffect
Remarks

https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/dropEffect

FileReaderJsInterop type

Namespace

Tewr.Blazor.FileReader

EndTask(taskId) method

Summary

Called from Js

Parameters
Name Type Description
taskId System.Int64

FileReaderServiceOptions type

Namespace

Tewr.Blazor.FileReader

MaximumRecieveMessageSize property

Summary

SignalR setting

UseBufferChunking property

Summary

Activates server-side buffer chunking. Activated if not running on WASM.

IBase64Stream type

Namespace

Tewr.Blazor.FileReader

Summary

Provides a base64-encoded string view of a sequence of bytes from a file.

Length property

Summary

Gets the length of the stream in bytes.

Position property

Summary

Gets or sets the current byte position in the Stream.

ReadAsync(offset,count,cancellationToken) method

Summary

Asynchronously reads a sequence of bytes as a base64 encoded string from the current stream and advances the position within the stream by the number of bytes read.

Returns

The requested sequence of bytes as a base64 encoded string. The resulting string can be shorter than the number of bytes requested if the number of bytes currently available is less than the requested number, or it can be string.empty if the end of the stream has been reached.

Parameters
Name Type Description
offset System.Int32 The byte offset in the source at which to begin reading data from the stream.
count System.Int32 The maximum number of bytes to read.
cancellationToken System.Threading.CancellationToken

IFileInfo type

Namespace

Tewr.Blazor.FileReader

Summary

Provides properties for file metadata.

LastModified property

Summary

Returns the last modified time of the file, in millisecond since the UNIX epoch (January 1st, 1970 at Midnight).

LastModifiedDate property

Summary

Returns the last modified time of the file.

Name property

Summary

Returns the name of the file referenced by the File object.

NonStandardProperties property

Summary

Returns a list of non-standard DOM properties attached to the object, like the webkitRelativePath property.

PositionInfo property

Summary

Returns information of the position of any stream related to this file.

Size property

Summary

Returns the size of the file in bytes.

Type property

Summary

Returns the MIME type of the file.

IFilePositionInfo type

Namespace

Tewr.Blazor.FileReader

Summary

Provides information on the position of a Stream currently reading this file.

DataStream property

Summary

The underlying stream that was the source of the Position change.

Percentage property

Summary

The current position of a Stream currently reading this file, relative to the file size.

PercentageDeltaSinceAcknowledge property

Summary

The delta between current Percentage and PercentageOnAcknowledge

PercentageOnAcknowledge property

Summary

The value of Percentage when Acknowledge was last called

Position property

Summary

The current position of a Stream currently reading this file.

PositionDeltaSinceAcknowledge property

Summary

The delta between current Position and what the value was at the last call to Acknowledge

PositionOnAcknowledge property

Summary

The value of Position when Acknowledge was last called

Acknowledge() method

Summary

Saves value of Position to PositionOnAcknowledge and Percentage to PercentageOnAcknowledge

Parameters

This method has no parameters.

Remarks

The saved values may also be comsumed as deltas from convenience properties PositionDeltaSinceAcknowledge and PercentageDeltaSinceAcknowledge

IFileReaderRef type

Namespace

Tewr.Blazor.FileReader

Summary

Provides methods for interacting with an element that provides file streams.

ClearValue() method

Summary

Clears any value set on the source element

Returns

An awaitable Task representing the operation

Parameters

This method has no parameters.

EnumerateFilesAsync() method

Summary

Enumerates the currently selected file references

Returns

An awaitable Task that provides an enumeration of the currently selected file references

Parameters

This method has no parameters.

RegisterDropEventsAsync(additive) method

Summary

Register for drop events on the source element

Returns

An awaitable task representing the operation

Parameters
Name Type Description
additive System.Boolean If set to true, drop target file list becomes additive. Defaults to false.

RegisterDropEventsAsync(dropEventsOptions) method

Summary

Register for drop events on the source element

Returns

An awaitable task representing the operation

Parameters
Name Type Description
dropEventsOptions Tewr.Blazor.FileReader.DropEvents.DropEventsOptions Provides expert options for manipulating the default javascript behaviour of the drag and drop events.

RegisterPasteEventAsync(additive) method

Summary

Register for paste events on the source element

Returns

An awaitable task representing the operation

Parameters
Name Type Description
additive System.Boolean If set to true, target file list becomes additive. Defaults to false.

RegisterPasteEventAsync(pasteEventOptions) method

Summary

Register for paste events on the source element

Returns

An awaitable task representing the operation

Parameters
Name Type Description
pasteEventOptions Tewr.Blazor.FileReader.DropEvents.PasteEventOptions Provides expert options for manipulating the default javascript behaviour of the paste events.

UnregisterDropEventsAsync() method

Summary

Unregister drop events on the source element

Returns

An awaitable Task representing the operation

Parameters

This method has no parameters.

UnregisterPasteEventAsync() method

Summary

Unregister paste events on the source element

Returns

An awaitable Task representing the operation

Parameters

This method has no parameters.

IFileReaderService type

Namespace

Tewr.Blazor.FileReader

Summary

Servive for creating a IFileReaderRef instance from an element.

CreateReference(element) method

Summary

Creates a new instance of IFileReaderRef for the specified element.

Returns

a new instance of IFileReaderRef

Parameters
Name Type Description
element Microsoft.AspNetCore.Components.ElementReference A reference to an element that can provide file streams.
Should be obtained using the @ref attribute.
Should reference either an input element of type file or a drop target.

EnsureInitializedAsync() method

Summary

Explicitly initializes this instance by loading the neccessary interop code to the browser.

Returns
Parameters

This method has no parameters.

IFileReaderServiceOptions type

Namespace

Tewr.Blazor.FileReader

Summary

Provides configuration options for IFileReaderService

InitializeOnFirstCall property

Summary

Initializes the file service on the first interop call. Redundant for client-side blazor.

Remarks

Initializing on the first call is neccessary only if the javascript interop file (FileReaderComponent.js) has not been loaded manually using a script tag.

UseWasmSharedBuffer property

Summary

For client-side blazor, uses shared memory buffer to transfer data quickly. Not available for server-side blazor.

IFileReference type

Namespace

Tewr.Blazor.FileReader

Summary

Provides properties and instance methods for the reading file metadata and aids in the creation of Readonly Stream objects.

CreateMemoryStreamAsync() method

Summary

Convenience method to read the file fully into memory using a single interop call and returns it as a MemoryStream. Buffer size will be equal to the file size. The length of the resulting MemoryStream will be the same as the file size.

Returns

A MemoryStream representing the full file, with Position set to 0.

Parameters

This method has no parameters.

Remarks

In most cases the fastest way to read a file into ram, but also the method that uses the most memory. Will use at least twice the file size of memory at the end of the read operation.

CreateMemoryStreamAsync() method

Summary

Convenience method to read the file fully into memory using a single interop call and returns it as a MemoryStream. Buffer size will be equal to the file size. The length of the resulting MemoryStream will be the same as the file size.

Returns

A MemoryStream representing the full file, with Position set to 0.

Parameters

This method has no parameters.

Remarks

In most cases the fastest way to read a file into ram, but the most expensive in memory usage. Will use at least twice the file size of memory at the end of the read operation.

CreateMemoryStreamAsync() method

Summary

Convenience method to read the file fully into memory represented as a MemoryStream, using the specified bufferSize. The length of the resulting MemoryStream will be the same as the file size.

Returns

A MemoryStream representing the full file, with Position set to 0.

Parameters

This method has no parameters.

CreateMemoryStreamAsync() method

Summary

Convenience method to read the file fully into memory represented as a MemoryStream, using the specified bufferSize. The length of the resulting MemoryStream will be the same as the file size.

Returns

A MemoryStream representing the full file, with Position set to 0.

Parameters

This method has no parameters.

GetJSObjectReferenceAsync() method

Summary

Returns the underlying file object as an 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.

OpenReadAsync() method

Summary

Opens a read-only Stream to read the file.

Returns

A read-only Stream to read the file.

Parameters

This method has no parameters.

OpenReadBase64Async() method

Summary

Opens a read-only base64-encoded string stream to read the file

Returns

A read-only IBase64Stream to read the file.

Parameters

This method has no parameters.

ReadFileInfoAsync() method

Summary

Reads the file metadata.

Returns

An object containing the file metadata

Parameters

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

Namespace

Tewr.Blazor.FileReader.DropEvents

Summary

Provides expert options for manipulating the default behaviour of the paste event.

Additive property

Summary

If set to true, paste target file list becomes additive. Defaults to false.

PlatformConfig type

Namespace

Tewr.Blazor.FileReader

IsWasm property

Summary

Returns true if the application is running on WASM.

TryReadMaximumReceiveMessageSize(serviceProvider,maximumReceiveMessageSize) method

Summary

Tries reading HubOptions.MaximumReceiveMessageSize using reflection.

Returns

true if the value could be sucessfully read.

Parameters
Name Type Description
serviceProvider System.IServiceProvider
maximumReceiveMessageSize System.Int64@

SetupExtension type

Namespace

Tewr.Blazor.FileReader

Summary

Provides extension methods for setting up IFileReaderService

AddFileReaderService(services) method

Summary

Adds IFileReaderService as a scoped service to the specified IServiceCollection.

Parameters
Name Type Description
services Microsoft.Extensions.DependencyInjection.IServiceCollection

AddFileReaderService(services,setOptions) method

Summary

Adds IFileReaderService as a scoped service to the specified IServiceCollection with the specifed setOptions

Parameters
Name Type Description
services Microsoft.Extensions.DependencyInjection.IServiceCollection
setOptions System.Action{Tewr.Blazor.FileReader.IFileReaderServiceOptions} Delegate that modifies the options for IFileReaderService