Skip to content

Latest commit

 

History

History
23 lines (20 loc) · 705 Bytes

OnBeforeDelete-event.md

File metadata and controls

23 lines (20 loc) · 705 Bytes

The OnBeforeDelete event is fired just before a file is deleted.

Calling FailRequest on the BeforeDeleteContext passed to the callback will reject the request with a 400 Bad Request status code. Calling FailRequest multiple times will concatenate the error messages.

app.UseTus(context => new DefaultTusConfiguration
{
    UrlPath = "/files",
    Store = new TusDiskStore(@"C:\tusfiles\"),
    Events = new Events
    {
        OnBeforeDeleteAsync = ctx =>
        {
            if(!SomeBusinessLogic())
            {
                ctx.FailRequest($"Cannot delete {ctx.FileId} due to business logic");
            }
            
            return Task.CompletedTask;
        }
    }
});