We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Using FileManager on NET6 without MVC

Hi.

Could you please provide a sample for using FileManager to view the file structure of the server with Blazor Server but without using MVC ?

Thank you.


8 Replies

SA SureshRajan Alagarsamy Syncfusion Team March 10, 2023 03:23 PM UTC

Hi Paulo,


Greetings from Syncfusion support.


We have validated your query and created a BlazorServer-FileManager sample as per your request. See the attached sample and let us know if it meets your requirements.


Additionally, we have also attached a link to the Blazor-FileManager demo and documentation for your reference.


Demo : https://blazor.syncfusion.com/demos/file-manager/overview?theme=fluent


Documentation : https://blazor.syncfusion.com/documentation/file-manager/getting-started


Regards,
Suresh.


Attachment: BlazorServerFileManager_75527764.zip


PP Paulo P March 11, 2023 12:15 PM UTC

In order to to view the file structure of the server file system, I need a class for supporting the actions of Read, Delete, Copy, Move, Get Details, Search, Rename, Create New Folder, File Download and File Upload without controllers (not using MVC).
Thank you very much.


SS Shereen Shajahan Syncfusion Team March 13, 2023 05:51 AM UTC

Hi Paulo,

Could you please confirm if the provided documentation served your purpose? If not, please update us with a detailed explanation of your requirements. We will be happy to assist you.

Regards,

Shereen




PP Paulo P March 13, 2023 11:26 AM UTC

Hi Shereen.

The demo you provided is the same presented in documentation.

I have a plain Blazor Server application (with no MVC), so I'd like you to provide a class equivalent to 

public class SampleDataController : Controller

but not using controllers.

Thank you.

 



SA SureshRajan Alagarsamy Syncfusion Team March 14, 2023 07:25 AM UTC

Hi Paulo,


File Manager has support to handle the data from the in-built operations (response from the default file operations of File Manager), and we do not have support to use File Manager without a backend. The File Manager works with the File Service Provider, which allows the component to manage the files and folders in a physical or cloud-based file system. You can find our available File Service providers at the below link.


Documentation : https://blazor.syncfusion.com/documentation/file-manager/file-system-provider


We recommend trying our hosted site in your browser, which provides a similar level of functionality to using File Manager without a backend. In our demo site, we have used the hosted link in FileManagerAjaxSettings. You can host your required File Provider and use the hosted link in your Blazor application. Refer to the below code snippet for further reference.


Code Snippet :


<SfFileManager TValue="FileManagerDirectoryContent">

    <FileManagerAjaxSettings Url=https://ej2-aspcore-service.azurewebsites.net/api/FileManager/FileOperations

                             UploadUrl=https://ej2-aspcore-service.azurewebsites.net/api/FileManager/Upload

                             DownloadUrl=https://ej2-aspcore-service.azurewebsites.net/api/FileManager/Download

                             GetImageUrl=https://ej2-aspcore-service.azurewebsites.net/api/FileManager/GetImage>

    </FileManagerAjaxSettings>

</SfFileManager>

 


Demo link : https://blazor.syncfusion.com/demos/file-manager/overview?theme=fluent


Check out the shared details and get back to us if you need any further assistance.


Regards,
Suresh.



PP Paulo P March 14, 2023 04:52 PM UTC

Hi Suresh.

The Blazor server application I have is not based in MVC architecture. So, how can I convert class  SampleDataController to a version not based on MVC?

Additionally, do you have any sample showing how to use File Manager to handle folders in a physical file system?

Thank you.



SA SureshRajan Alagarsamy Syncfusion Team March 27, 2023 06:54 PM UTC

Hi paulo,


We have reviewed your shared details and understand that you don’t want MVC controller structure in the File Manager component. We would like to inform you that we have maintained both Core and MVC structure in our all service file providers.


We have attached the Asp.Net Core physical file provider as per your request. Please find the link here:

https://github.com/SyncfusionExamples/ej2-aspcore-file-provider


Regarding your other query, we would like to clarify if you are looking for Directory Upload requirement in File Manager or File Operations like read, copy, delete, and download in File Manager.


If you are looking for directory upload, please refer to this demo link:

https://blazor.syncfusion.com/demos/file-manager/directory-upload?theme=fluent


For File Operations, we have provided methods in our Controller part to handle files and folders. Please refer to the below code snippet for further reference.


Code snippet :


[FileManagerController]

 

[Route("FileOperations")]

public object FileOperations([FromBody] FileManagerDirectoryContent args)

{

  if (args.Action == "delete" || args.Action == "rename")

  {

    if ((args.TargetPath == null) && (args.Path == ""))

    {

      FileManagerResponse response = new FileManagerResponse();

      response.Error = new ErrorDetails { Code = "401", Message = "Restricted to modify the root folder." };

      return this.operation.ToCamelCase(response);

    }

  }

  switch (args.Action)

  {

    case "read":

    // reads the file(s) or folder(s) from the given path.

    return this.operation.ToCamelCase(this.operation.GetFiles(args.Path, args.ShowHiddenItems));

    case "delete":

    // deletes the selected file(s) or folder(s) from the given path.

    return this.operation.ToCamelCase(this.operation.Delete(args.Path, args.Names));

    case "copy":

    // copies the selected file(s) or folder(s) from a path and then pastes them into a given target path.

    return this.operation.ToCamelCase(this.operation.Copy(args.Path, args.TargetPath, args.Names, args.RenameFiles, args.TargetData));

    case "move":

    // cuts the selected file(s) or folder(s) from a path and then pastes them into a given target path.

    return this.operation.ToCamelCase(this.operation.Move(args.Path, args.TargetPath, args.Names, args.RenameFiles, args.TargetData));

    case "details":

    // gets the details of the selected file(s) or folder(s).

    return this.operation.ToCamelCase(this.operation.Details(args.Path, args.Names, args.Data));

    case "create":

    // creates a new folder in a given path.

    return this.operation.ToCamelCase(this.operation.Create(args.Path, args.Name));

    case "search":

    // gets the list of file(s) or folder(s) from a given path based on the searched key string.

    return this.operation.ToCamelCase(this.operation.Search(args.Path, args.SearchString, args.ShowHiddenItems, args.CaseSensitive));

    case "rename":

    // renames a file or folder.

    return this.operation.ToCamelCase(this.operation.Rename(args.Path, args.Name, args.NewName));

  }

  return null;

}

 


Check out the shared details and get back to us if you need any further assistance.


Regards,
Suresh.



PP Paulo P March 30, 2023 10:33 AM UTC

Thank you.


Loader.
Up arrow icon