Ensure you have the following installed:
- .NET 8 SDK: Download & Install .NET 8
- SQL Server: A running instance of SQL Server Express LocalDB.
- .NET EF Core Tools: Install the command-line tools for Entity Framework Core.
dotnet tool install --global dotnet-ef
The database connection string don't need to be configured before running the application, but if needed, it can be.
- Open the
appsettings.jsonfile located atFileBrowser.Api/appsettings.json. - Locate the
ConnectionStringssection. - Update the
FileBrowserConnectionvalue with the connection string for your SQL Server instance.
Example appsettings.json:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"ConnectionStrings": {
"FileBrowserConnection": "Server=(localdb)\\MSSQLLocalDB;Database=FileBrowserDb;Trusted_Connection=true;"
},
"AllowedHosts": "*"
}To run SQL Server LocalDb which is used for this project, run following command:
sqllocaldb start MSSQLLocalDBThis project uses Entity Framework Core for database migrations. To create and seed the database, run the following command from the root directory of the project:
dotnet ef database update --project FileBrowser.DataThis command will read the connection string from FileBrowser.Api/appsettings.json, create the database if it doesn't exist, and apply all migrations to set up the required tables.
You can run the application directly using the .NET CLI.
-
Build the solution:
dotnet build
-
Run the API project:
dotnet run --project FileBrowser.Api --launch-profile https
By default, the API will be available at https://localhost:7262 and http://localhost:5126.
Or you can test API's with swagger: https://localhost:7262/swagger/index.html and http://localhost:5126/swagger/index.html
Once the application is running, you can interact with the API.
-
Swagger UI: A Swagger UI will be available at
/swaggerfor exploring and testing the API endpoints. (e.g.,https://localhost:7262/swagger/index.html,http://localhost:5126/swagger/index.html) -
Main Endpoints:
-
GET /api/folders: Retrieves all folders. -
GET /api/folders/{id}: Retrieves a specific folder by its Id. -
POST /api/folders: Creates a new folder. -
PUT /api/folders/{id}: Updates an existing folder. -
DELETE /api/folders/{id}: Deletes a folder by Id. -
GET /api/folders/subfolders/{parentId}: Retrieves all files and folders within a specific folder. -
GET /api/files: Retrieves all files. -
GET /api/files/{id}: Retrieves a specific file by its Id. -
POST /api/files: Creates a new file. -
PUT /api/files/{id}: Updates an existing file. -
DELETE /api/file/{id}: Deletes a file by Id. -
GET /api/file/folder/{folderId}: Retrieves all files within a specific folder. -
GET /api/file/search: Search files across all folders by file name. -
GET /api/file/search-in-folder/{folderId}: Search files in a specific folder by file name.
-