This is a migrated thread and some comments may be shown as answers.

Server Side upload failure - informing the user

1 Answer 105 Views
FileManager
This is a migrated thread and some comments may be shown as answers.
Ross
Top achievements
Rank 1
Ross asked on 19 Mar 2020, 01:59 PM

Hi

I am implementing the FileManager, but I have come across a problem. When the server side upload fails, this doesn't raise the Error event, instead controls swallows the error and dumps it to the console. If there server side fails, I would like to alert the user and give more details feedback, how could I accomplish this?

In the code below I have set the error method and the action method straight up throws an exception, i also tried this just returning StatusCode(500)

<div>
    @(Html.Kendo().FileManager()
        .Name("filemanager")
        .DataSource(ds =>
        {
            ds.ServerFiltering(true);
            ds.Read(operation => operation
                .Type(HttpVerbs.Post)
                .Action("ReadDocument", "Home")
                );
            ds.Destroy(operation => operation
                .Type(HttpVerbs.Post)
                .Action("DestroyDocument", "Home")
                );
            ds.Create(operation => operation
                .Type(HttpVerbs.Post)
                .Action("CreateDocument", "Home")
                );
            ds.Update(operation => operation
                .Type(HttpVerbs.Post)
                .Action("UpdateDocument", "Home")
                );
        })
        .UploadUrl("Upload", "Home")

       .Events(e => e
            .Error("onError")
        )
        )
</div>


<script>
    function onError(e) {
        console.log("there is an error");
        debugger;
      
    };
    function onOpen(e) {
        debugger;
    };
</script>

 

 

---controller---

[HttpPost]
        public IActionResult Upload(IFormFile file, string path)
        {
            throw new NotImplementedException("error");
        }

 

 

Ross

1 Answer, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 24 Mar 2020, 08:25 AM

Hello Ross,

Unfortunately, at this stage, the FileManager HTML helper does not expose the appropriate configuration options that would allow you to catch an Upload error. That would be the Error event of the embedded in the FileManager Upload widget. Having that said, I have logged the following feature request on your behalf:

https://feedback.telerik.com/aspnet-core-ui/1458862-expose-upload-error-event-in-the-filemanager-html-helper-configuration

Please, do not forget to cast your vote for the above.

As a temporary workaround, you could attach the error event handler to the client instance of the Upload widget:

$(document).ready(function () {
    var fm = $("#filemanager").getKendoFileManager();
    fm.upload.bind("error", function (e) {
        alert(e.XMLHttpRequest.statusText);
    })
});

Regards,
Veselin Tsvetanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
FileManager
Asked by
Ross
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Share this question
or