-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Closed
Labels
Description
Hi, I am working with Input File, and I want to use it to upload content, including: photos, videos, audio, but before uploading I want the user to see a preview of the content to be uploaded, and then upload But the output of the input file must be streamed and then converted to bytes and then converted to Base64 so that it can be displayed and usable. Depending on the file size, this may take a few seconds (for example, 10 seconds), and this is really awful. Do you have a better solution other than using JavaScript, to show a preview to the user faster?
I'm using blazor WASM .net 6.0.0-preview.7.21378.6
InputFileChangeEventArgs e
if (item.ContentType.StartsWith("image"))
{
var format = "image/png";
imgFile = await e.File.RequestImageFileAsync(format, 100, 100); //What I did here was to reduce the size of the image, but to no avail
}
if (item.ContentType.StartsWith("image") || item.ContentType.StartsWith("video"))
{
await imgFile.OpenReadStream(1073857600).ReadAsync(buffers); //I mean this part that takes a long time
string imageType = imgFile.ContentType;
Url = $"data:{imageType};base64,{Convert.ToBase64String(buffers)}";
}