Exemple #1
0
        internal async Task <IBrowserFile> ConvertToImageFileAsync(BrowserFile file, string format, int maxWidth, int maxHeight)
        {
            var imageFile = await JSRuntime.InvokeAsync <BrowserFile>(InputFileInterop.ToImageFile, _inputFileElement, file.Id, format, maxWidth, maxHeight);

            imageFile.Owner = this;

            return(imageFile);
        }
        public RemoteBrowserFileStream(
            IJSRuntime jsRuntime,
            ElementReference inputFileElement,
            BrowserFile file,
            RemoteBrowserFileStreamOptions options,
            CancellationToken cancellationToken)
            : base(file)
        {
            _jsRuntime           = jsRuntime;
            _inputFileElement    = inputFileElement;
            _maxSegmentSize      = options.SegmentSize;
            _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);
        }
 protected BrowserFileStream(BrowserFile file)
 {
     File = file;
 }
Exemple #4
0
 public SharedBrowserFileStream(IJSRuntime jsRuntime, IJSUnmarshalledRuntime jsUnmarshalledRuntime, ElementReference inputFileElement, BrowserFile file)
     : base(file)
 {
     _jsRuntime             = jsRuntime;
     _jsUnmarshalledRuntime = jsUnmarshalledRuntime;
     _inputFileElement      = inputFileElement;
 }
Exemple #5
0
 internal Stream OpenReadStream(BrowserFile file, CancellationToken cancellationToken)
 => _jsUnmarshalledRuntime != null ?
 (Stream) new SharedBrowserFileStream(JSRuntime, _jsUnmarshalledRuntime, _inputFileElement, file) :
 new RemoteBrowserFileStream(JSRuntime, _inputFileElement, file, Options.Value, cancellationToken);