/// <summary> /// Executes the POST method on the resource. /// </summary> /// <param name="Request">HTTP Request</param> /// <param name="Response">HTTP Response</param> /// <exception cref="HttpException">If an error occurred when processing the method.</exception> public Task POST(HttpRequest Request, HttpResponse Response) { Gateway.AssertUserAuthenticated(Request, "Admin.Data.Backup"); if (!Request.HasData) { throw new BadRequestException(); } if (!(Request.DecodeData() is string FileName)) { throw new BadRequestException(); } string Dir; if (FileName.EndsWith(".key", StringComparison.CurrentCultureIgnoreCase)) { Dir = Export.FullKeyExportFolder; } else { Dir = Export.FullExportFolder; } if (!Directory.Exists(Dir)) { throw new NotFoundException("Folder not found: " + Dir); } string FullFileName = Dir + Path.DirectorySeparatorChar + FileName; if (!File.Exists(FullFileName)) { throw new NotFoundException("File not found: " + FullFileName); } File.Delete(FullFileName); Log.Informational("Export deleted.", FileName); Response.StatusCode = 200; Response.ContentType = "text/plain"; Response.Write("1"); ExportFormat.UpdateClientsFileDeleted(FileName); return(Task.CompletedTask); }