File Transfer Protocol file system provider

29 Nov 20242 minutes to read

In ASP.NET Core, File Transfer Protocol file system provider allows the users to access to the hosted file system as collection of objects stored in the file storage using File Transfer Protocol. To get started, clone the EJ2.ASP.NET Core FTP File Provider using the following command


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

After cloning, open the project in Visual Studio and restore the NuGet packages. Now, register File Transfer Protocol details like hostName, userName and password in SetFTPConnection method in the FileManager controller to perform the file operations.

 void SetFTPConnection(string hostName, string userName, string password)

After registering the File Transfer Protocol details, just build and run the project. Now, the project will be hosted in http://localhost:{port} and just mapping the ajaxSettings property of the FileManager component to the appropriate controller methods allows you to manage the FTP’s objects storage.

@*Initializing File Manager with File Transfer Protocol service*@

@* Replace the hosted port number in the place of "{port}" *@

<SfFileManager TValue="FileManagerDirectoryContent">
    <FileManagerAjaxSettings Url="http://localhost:{port}/api/FTPProvider/FTPFileOperations"
                             UploadUrl="http://localhost:{port}/api/FTPProvider/FTPUpload"
                             DownloadUrl="http://localhost:{port}/api/FTPProvider/FTPDownload"
                             GetImageUrl="http://localhost:{port}/api/FTPProvider/FTPGetImage">
    </FileManagerAjaxSettings>
</SfFileManager>

To perform file operations (Read, Create, Rename, Delete, Get file details, Search, Copy, Move, Upload, Download, GetImage) in the Syncfusion® Blazor File Manager component using the File Transfer Protocol file system provider, you need to initialize the File Transfer Protocol file system provider in the controller.

To initialize a local service with the above-mentioned file operations, create a new folder named Controllers inside the server part of the project. Then, create a new file with the extension .cs inside the Controllers folder and add the necessary file operations code available in the FTPProviderController.cs found at this link. Additionally, you can check out all the necessary file operation method details for this provider in the same GitHub repository.

NOTE

To learn more about the file actions that can be performed with File Transfer Protocol file system provider, refer to this link