Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor syncfusion Filemanager

$
0
0

I just started using syncfusion and I find myself in trouble for the FILEMANAGER, basically I followed the guide https://www.youtube.com/watch?v=qcH3B8FTPao following step by step but in the end I receive an error NetworkError:Failed to send on XMLHTTPRequest:Failed to load https://localhost:7225/api/FileManager/FileOperations searching on vai forum it would seem that the problem is baseurl but I can't find a solution, is there anyone who has already hadenter image description here

the same error and found the solution?my code is following

FileManagerController.csusing Microsoft.AspNetCore.Http.Features;using Microsoft.AspNetCore.Mvc;using Newtonsoft.Json;using Syncfusion.EJ2.FileManager.Base;using Syncfusion.EJ2.FileManager.PhysicalFileProvider;namespace LawSync.Controllers{    [Route("api/[controller]")]    [IgnoreAntiforgeryToken]    public class FileManagerController : Controller    {            string basePath;            PhysicalFileProvider operation;            public FileManagerController(IWebHostEnvironment hostingEnvironment)            {                basePath = hostingEnvironment.ContentRootPath;                operation = new PhysicalFileProvider();                operation.RootFolder(basePath +"\\Data\\Files");            }        [Route("FileOperations")]            public object FileOperations([FromBody] FileManagerDirectoryContent args)            {                switch (args.Action)                {                    // Add your custom action here                    case "read":                        // Path - Current path; ShowHiddenItems - Boolean value to show/hide hidden items                        return this.operation.ToCamelCase(this.operation.GetFiles(args.Path, args.ShowHiddenItems));                    case "delete":                        // Path - Current path where of the folder to be deleted; Names - Name of the files to be deleted                        return this.operation.ToCamelCase(this.operation.Delete(args.Path, args.Names));                    case "copy":                        //  Path - Path from where the file was copied; TargetPath - Path where the file/folder is to be copied; RenameFiles - Files with same name in the copied location that is confirmed for renaming; TargetData - Data of the copied file                        return this.operation.ToCamelCase(this.operation.Copy(args.Path, args.TargetPath, args.Names, args.RenameFiles, args.TargetData));                    case "move":                        // Path - Path from where the file was cut; TargetPath - Path where the file/folder is to be moved; RenameFiles - Files with same name in the moved location that is confirmed for renaming; TargetData - Data of the moved file                        return this.operation.ToCamelCase(this.operation.Move(args.Path, args.TargetPath, args.Names, args.RenameFiles, args.TargetData));                    case "details":                        // Path - Current path where details of file/folder is requested; Name - Names of the requested folders                        return this.operation.ToCamelCase(this.operation.Details(args.Path, args.Names));                    case "create":                        // Path - Current path where the folder is to be created; Name - Name of the new folder                        return this.operation.ToCamelCase(this.operation.Create(args.Path, args.Name));                    case "search":                        // Path - Current path where the search is performed; SearchString - String typed in the searchbox; CaseSensitive - Boolean value which specifies whether the search must be casesensitive                        return this.operation.ToCamelCase(this.operation.Search(args.Path, args.SearchString, args.ShowHiddenItems, args.CaseSensitive));                    case "rename":                        // Path - Current path of the renamed file; Name - Old file name; NewName - New file name                        return this.operation.ToCamelCase(this.operation.Rename(args.Path, args.Name, args.NewName));                }                return null;            }            [Route("Download")]            public IActionResult Download(string downloadInput)            {                FileManagerDirectoryContent content = JsonConvert.DeserializeObject<FileManagerDirectoryContent>(downloadInput);                return operation.Download(content.Path, content.Names);            }            [Route("Upload")]            public IActionResult Upload(string path, IList<IFormFile> uploadFiles, string action)            {                FileManagerResponse uploadResponse = operation.Upload(path, uploadFiles, action, null);                if (uploadResponse.Error != null)                {                    Response.Clear();                    Response.ContentType = "application/json; charset=utf-8";                    Response.StatusCode = Convert.ToInt32(uploadResponse.Error.Code);                    Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = uploadResponse.Error.Message;                }                return Content("");            }            [Route("GetImage")]            public IActionResult GetImage(FileManagerDirectoryContent args)            {                return operation.GetImage(args.Path, null, false, null, null);            }    }}

and blazor page is next

@page "/Test"@using Syncfusion.Blazor.FileManager@* @rendermode InteractiveServer *@<SfFileManager TValue="FileManagerDirectoryContent"><FileManagerAjaxSettings Url="/api/FileManager/FileOperations"                             DownloadUrl="/api/FileManager/Download"                             UploadUrl="/api/FileManager/Upload"                             GetImageUrl="/api/FileManager/GetImage"></FileManagerAjaxSettings></SfFileManager>Thank you

Viewing all articles
Browse latest Browse all 4839

Trending Articles