private async Task <Stream> OpenReadStreamAsync(RemoteBrowserFileStreamOptions options, CancellationToken cancellationToken) { var dataReference = await _jsRuntime.InvokeAsync <IJSStreamReference>( InputFileInterop.ReadFileData, cancellationToken, _inputFileElement, File.Id); return(await dataReference.OpenReadStreamAsync(_maxAllowedSize, options.MaxBufferSize, cancellationToken)); }
public RemoteBrowserFileStream( IJSRuntime jsRuntime, ElementReference inputFileElement, BrowserFile file, RemoteBrowserFileStreamOptions options, long maxAllowedSize, CancellationToken cancellationToken) : base(file) { _jsRuntime = jsRuntime; _inputFileElement = inputFileElement; _maxAllowedSize = maxAllowedSize; _openReadStreamCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); OpenReadStreamTask = OpenReadStreamAsync(options, _openReadStreamCts.Token); }
public RemoteBrowserFileStream( IJSRuntime jsRuntime, ElementReference inputFileElement, BrowserFile file, RemoteBrowserFileStreamOptions options, CancellationToken cancellationToken) : base(file) { _jsRuntime = jsRuntime; _inputFileElement = inputFileElement; _maxSegmentSize = options.MaxSegmentSize; _segmentFetchTimeout = options.SegmentFetchTimeout; var pipe = new Pipe(new PipeOptions(pauseWriterThreshold: options.MaxBufferSize, resumeWriterThreshold: options.MaxBufferSize)); _pipeReader = pipe.Reader; _fillBufferCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); _ = FillBuffer(pipe.Writer, _fillBufferCts.Token); }