Rename Image on upload in RichTextEditor In Blazor web assembly

Hi,

I'm trying to rename added images in the rich text editor. I have followed the tutorial, but it seems that for blazor wasm the headers are filtered out. I can see that the server returns the added headers, but they're not available in the ImageSuccessEventArgs.


I have tested the same with blazor server and there it seems to work fine.


I looked as this thread also, but it doesn't specify if it's server or wasm.

https://www.syncfusion.com/forums/157797/rename-image-on-upload-in-richtexteditor


5 Replies

IS Indrajith Srinivasan Syncfusion Team November 15, 2021 12:03 PM UTC

Hi Marcel, 
 
Greetings from Syncfusion support, 
 
We have validated your reported query “but it seems that for blazor wasm the headers are filtered out. I can see that the server returns the added headers, but they're not available in the ImageSuccessEventArgs”. The response received combines the images with the header added. You can get the image headers by splitting the name attribute of the received string. Check the below shared code blocks for reference. 
 
Code blocks: 
 
Index.razor 
 
 
private void onSuccess(ImageSuccessEventArgs args) 
    { 
        var headers = args.Response.Headers.ToString(); 
        header = headers.Split("name: "); 
        header = header[1].Split("\r"); 
        args.File.Name = header[0]; 
    } 
 
 
 
Please let us know if the solution helps, 
 
Regards, 
Indrajith 



MA Marcel November 15, 2021 04:04 PM UTC

Hi Indrajith,


This is exactly the example i've run. I can see the headers being returned, but they don't exist in the ImageSuccessEventArgs:





When I run the exact same code from a blazor server side application it does work. So it seems they are being filtered out somewhere in the code? A similar issue (for javascript) existed earlier:
https://www.syncfusion.com/forums/150534/rename-images-before-inserting-it-in-richtexteditor


Best regards,

Marcel



IS Indrajith Srinivasan Syncfusion Team November 16, 2021 06:28 AM UTC

Hi Marcel, 
 
We have further validated the issue in the above shared sample, and still unable to reproduce the reported issue from our end. Check the below shared screenshots and already shared sample for reference. 
 
  
Screenshots: 
 
  • Image name added in headers.
 
 
 
  • Modified name in headers is received in the OnImageUploadSuccess event of the editor.
 
 
Can you please share us the following details ? 
 
  • Are you facing issue in the above shared sample ?
  • The Nuget package version you are using ?
  • If possible, can you please share us a minimum issue reproducing sample to validate the issue from our end ?
 
Regards, 
Indrajith 



MA Marcel November 16, 2021 08:46 PM UTC

Hi Indrajith,


First of all, thank you for the fast and accurate replies!

I've ran the sample you supplied and that is working fine, I receive all headers on the client side.

The difference between this and my setup is, is that my API is running on a different address, so I have to setup some basic CORS settings and it seems I have missed to set the correct Access Control Expose Headers.


The problem was with my CORS setup and not with the syncfusion controls. 
Adding: 

.WithExposedHeaders("name");  to my Cors policy on the serverside fixed the problem.


Thank you for your help and my apologies for your invested time.


Best regards,


- Marcel



IS Indrajith Srinivasan Syncfusion Team November 17, 2021 04:49 AM UTC

Hi Marcel,

Thanks for the update,

We are glad that you found a solution for the reported issue. Please get back to us if you need any further assistance.

Regards,
Indrajith

Loader.
Up arrow icon