SyncfusionExamples/sql-server-database-aspcore-file-provider

Repository files navigation

This repository contains the SQL server database file provider in ASP.NET Core for the Syncfusion File Manager component.

To know more about SQL server database file system provider for File Manager, please refer our documentation [here] (https://ej2.syncfusion.com/aspnetcore/documentation/file-manager/file-system-provider#sql-database-file-system-provider).

The SQL FILESTREAM feature provides efficient storage, management, and of unstructured data stored as files on the file system.

The SQL server database file provider serves the file system support for the FileManager component in SQL server database.

The following actions can be performed with the SQL server database file provider.

ActionsDescription
ReadRead the files from SQL table.
DetailsGets a file's details which consists of Type, Size, Location and Modified date.
DownloadDownloads the selected file or folder from the SQL table.
UploadUploads a file to the SQL table. It accepts uploaded media with the following characteristics:
  • Maximum file size: 30MB
  • Accepted Media MIME types: */*
CreateCreates a New folder.
DeleteDeletes a folder or file.
CopyCopys the selected Files from target.
MovePastes the copied files to the desired location.
RenameRenames a folder or file.
SearchFull-text queries perform linguistic searches against text data in full-text indexes by operating on words and phrases.
  • Visual Studio 2022

Make the SQL server connection with SQL database file (App_Data/FileManager.mdf) and specify the connection string in "Web.config" file as specified in below code example.


<add name="FileExplorerConnection" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\FileManager.mdf;Integrated Security=True;Trusted_Connection=true" />

Also need to add the entry for the connection string in the appsettings.json file as specified in below code example.


{
  "ConnectionStrings": {
    "FileManagerConnection": "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\\App_Data\\FileManager.mdf;Integrated Security=True;Connect Timeout=30"
  }
}

To configure the SQL server database connection use the SetSQLConnection method to set the connection name, table name and rootId of the table.

  
  SetSQLConnection(string name, string tableName, string tableID)

  • Checkout this project to a location in your disk.
  • Open the solution file using Visual Studio 2022.
  • Restore the NuGet packages by rebuilding the solution.
  • Run the project.

To access the basic actions such as Read, Delete, Copy, Move, Rename, Search, and Get Details of File Manager using the SQL server database file provider service, just map the following code snippet in the Ajaxsettings property of File Manager.

Here, the hostUrl will be your locally hosted port number.

  var hostUrl = http://localhost:62870/;
  ajaxSettings: {
        url: hostUrl + 'api/SQLProvider/SQLFileOperations'
  }

To perform download operation, initialize the downloadUrl property in ajaxSettings of the File Manager component.

  var hostUrl = http://localhost:62870/;
  ajaxSettings: {
        url: hostUrl + 'api/SQLProvider/SQLFileOperations',
        downloadUrl: hostUrl + 'api/SQLProvider/SQLDownload'
  }

To perform upload operation, initialize the uploadUrl property in ajaxSettings of the File Manager component.

  var hostUrl = http://localhost:62870/;
  ajaxSettings: {
        url: hostUrl + 'api/SQLProvider/SQLFileOperations',
        uploadUrl: hostUrl + 'api/SQLProvider/SQLUpload'
  }

To perform image preview support in the File Manager component, initialize the getImageUrl property in ajaxSettings of the File Manager component.

  var hostUrl = http://localhost:62870/;
  ajaxSettings: {
        url: hostUrl + 'api/SQLProvider/SQLFileOperations',
         getImageUrl: hostUrl + 'api/SQLProvider/SQLGetImage'
  }

The FileManager will be rendered as the following.

File Manager

Product support is available for through following mediums.

Check the license detail here.

Check the changelog here

Copyright 2023 Syncfusion, Inc. All Rights Reserved. The Syncfusion Essential Studio license and copyright applies to this distribution.

About

This repository contains the SQL server database file provider in ASP.NET Core for the Syncfusion File Manager component.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 15

Languages