Skip to content

[#61826] Add blob() method to DotNetStreamReference - #66679

Closed
andersabjorn wants to merge 4 commits into
dotnet:mainfrom
andersabjorn:feature/add-blob-method-dotnetstream
Closed

andersabjorn wants to merge 4 commits into
dotnet:mainfrom
andersabjorn:feature/add-blob-method-dotnetstream

Conversation

@andersabjorn

Copy link
Copy Markdown

Add blob() method to DotNetStreamReference

Description

This PR implements the blob() method for DotNetStreamReference as requested in issue #61826.

Changes Made:

  • Add async blob(mimeType?: string): Promise<Blob> method to DotNetStream class in Microsoft.JSInterop.ts
  • Update JavaScript interop tests in jsinteroptests.js to validate blob functionality
  • Method allows optional MIME type parameter for content-type headers
  • Follows the same pattern as existing arrayBuffer() method

Usage Example:

// Get stream data as a Blob
const blob = await dotNetStreamRef.blob('application/pdf');

// Create download link
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.pdf';
a.click();

// Display image
const img = document.createElement('img');
img.src = URL.createObjectURL(blob);

Fixes #61826

- Add async blob() method to DotNetStream class in Microsoft.JSInterop.ts
- Update JavaScript interop tests to validate blob functionality
- Method allows optional MIME type parameter for content-type headers

Fixes dotnet#61826
@andersabjorn
andersabjorn requested a review from a team as a code owner May 14, 2026 07:53
@github-actions github-actions Bot added the area-blazor Includes: Blazor, Razor Components label May 14, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label May 14, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Thanks for your PR, @andersabjorn. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@andersabjorn

Copy link
Copy Markdown
Author

@dotnet-policy-service agree

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime.
To make sure no conflicting changes have occurred, please rerun validation before merging. You can do this by leaving an /azp run comment here (requires commit rights), or by simply closing and reopening.

@dotnet-policy-service dotnet-policy-service Bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Sep 26, 2026
@andersabjorn

Copy link
Copy Markdown
Author

Updated the branch with main. CI is waiting on maintainer approval for the workflow run — happy to address any review feedback once checks are green. Thanks!

@kotlarmilos

Copy link
Copy Markdown
Member

Thanks for the contribution. This PR only changes the test and calls blob() after arrayBuffer() has consumed the stream. Apps can already create a Blob with new Response(await streamRef.stream()).blob(), so a separate JS API does not seem necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components community-contribution Indicates that the PR has been added by a community member pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Design proposal: #47685 Add blob() method to JS side of Blazor DotNetStreamReference

2 participants