Null argument passed when using saveUrl for images in RichTextEditor

I have a RichTextEditor component with insertImageSettings { saveUrl: ... }:

var RichTextEditor = new ej.richtexteditor.RichTextEditor({
    height: "95%",
    enablePersistence: false,
    enableHtmlSanitizer: false,
    insertImageSettings: {
        saveUrl: 'https://docs.dpiserve.com:20410/api/v1/PJMDocs/SaveImage',
    },

The API endpoint works and is hit when an image is inserted into the editor. 

It only started working when I set the API method to use [FromForm]:

[HttpPost("SaveImage")]
public IActionResult SaveImage([FromForm] object? uploadFiles)


I have tried various types in place of "object?" including just a string? variable as well as a record object.

In each case the incoming argument is null. If I use anything other than [FromForm] then I get a media type error returned from the API endpoint.

I also have not found an definition for the UploadFiles object that is supposed to be sent with the image save request.

So my two questions are:

  1. Why is the argument to the API call coming in as null?
  2. What is the UploadiFile object supposed to look like when it is received?
Thank you.

1 Reply

VY Vinothkumar Yuvaraj Syncfusion Team October 14, 2024 11:59 AM UTC

Hi Bradley Brown,


We have validated your reported query, and the correct way to handle file uploads in ASP.NET Core is by using IFormFile. This allows the API to accept a collection of files in the request, which works when receiving multiple images on the server.


Please see the following code for your reference:

[AcceptVerbs("Post")] [EnableCors("AllowAllOrigins")] [Route("SaveFile")] public IActionResult SaveFile(IFormFile UploadFiles) { // Your file handling logic here }


Please let us know if you have any further questions or concerns.


Regards,
Vinothkumar


Loader.
Up arrow icon