Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
datvm opened this issue Apr 13, 2023 · 4 comments
Open
1 task done

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

datvm opened this issue Apr 13, 2023 · 4 comments
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one good first issue Good for newcomers.
Milestone

Comments

@datvm
Copy link

datvm commented Apr 13, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

Right now the Streams passed from .NET to Javascript through DotNetStreamReference expose two methods: stream() and arrayBuffer(). The former doesn't read the whole stream into memory but there's not much support for it (for example in my case, playing video without knowing the codec, see question on StackOverflow). The latter would load the entire stream/file into memory which is not possible for large files like videos.

I am also not aware of any method to convert a ReadableStream into Blob.

Describe the solution you'd like

Add a blob([mimeType: string]) method to the Javascript stream reference object that returns a Blob. This Blob should not load all the data into memory.

Additional context

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label Apr 13, 2023
@datvm datvm changed the title Add blob() method to JS side of DotNetStreamReference Add blob() method to JS side of Blazor DotNetStreamReference Apr 13, 2023
@MackinnonBuck MackinnonBuck added area-blazor Includes: Blazor, Razor Components good first issue Good for newcomers. and removed needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically labels Apr 13, 2023
@MackinnonBuck
Copy link
Member

Thanks for reaching out. If this is something that you're interested in contributing, please feel free to open a PR. The feature would most likely need to be implemented here.

@MackinnonBuck MackinnonBuck added this to the Backlog milestone Apr 13, 2023
@ghost
Copy link

ghost commented Apr 13, 2023

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@datvm
Copy link
Author

datvm commented Apr 16, 2023

The feature would most likely need to be implemented here.

Hi sorry for late response I just got some time to take a look at it today. I do not know how to test a Blazor project from aspnetcore repo so I made a simple method to test it by myself to see if it works. According to the arrayBuffer implementation (new Response(await this.stream()).arrayBuffer()), I made this code that call blob() instead:

async setStreamAsync(netStream, mime) {
    const stream = await netStream.stream();
    const res = new Response(stream, {
        status: 200,
        statusText: "OK",
        headers: {
            "Content-Type": mime,
        }
    });
    const blob = await res.blob();

    this.#vid.src = URL.createObjectURL(blob);
}

However, at await res.blob(), the whole file is loaded into memory and it takes a very long time. So sorry I do not know a good implementation for this issue.

@mkArtakMSFT mkArtakMSFT modified the milestones: Backlog, BlazorPlanning Nov 5, 2023
@MackinnonBuck MackinnonBuck modified the milestones: Planning: WebUI, Backlog Dec 4, 2023
@MackinnonBuck MackinnonBuck added the enhancement This issue represents an ask for new feature or an enhancement to an existing one label Dec 4, 2023
@ghost
Copy link

ghost commented Dec 4, 2023

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@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 Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@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 Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
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 enhancement This issue represents an ask for new feature or an enhancement to an existing one good first issue Good for newcomers.
Projects
None yet
Development

No branches or pull requests

4 participants