This ASP.NET Web API provides endpoints for seamless file uploading, downloading, listing, updating, and deleting operations. It simplifies the process of handling various file types, including image uploads. The API is built on the ASP.NET framework and leverages the Entity Framework for data storage.
- Endpoint:
POST /api/File/Upload
- Request:
- Form Data:
file
(IFormFile)
- Form Data:
- Response:
- If successful, returns the ID of the uploaded file.
- Endpoint:
GET /api/File/{id}
- Request:
- Path Parameter:
id
(int)
- Path Parameter:
- Response:
- Downloads the file associated with the specified ID.
- Endpoint:
GET /api/File/List
- Response:
- Returns a list of filenames.
- Endpoint:
DELETE /api/File/{id}
- Request:
- Path Parameter:
id
(int)
- Path Parameter:
- Response:
- Deletes the file associated with the specified ID.
- Endpoint:
PUT /api/File/{id}
- Request:
- Path Parameter:
id
(int) - Form Data:
file
(IFormFile)
- Path Parameter:
- Response:
- Updates the file associated with the specified ID.
- Endpoint:
POST /api/File/UploadImage
- Request:
- Form Data:
image
(IFormFile)
- Form Data:
- Response:
- If successful, returns the ID of the uploaded image.
- Endpoint:
POST /api/File/UploadMultipleFiles
- Request:
- Form Data:
files
(List)
- Form Data:
- Response:
- If successful, uploads multiple files.
- Clone the repository.
git clone https://github.com/yourusername/AspNetFileManagementWebAPI.git
- .NET 8 SDK
- Microsoft.EntityFrameworkCore
- Microsoft.EntityFrameworkCore.SqlServer
- Microsoft.EntityFrameworkCore.Tools
# Install the .NET 8 SDK
# Visit https://dotnet.microsoft.com/download/dotnet/8.0 to download and install the SDK
# Skip this step if you already have .NET 8 installed
dotnet --version
# Install Entity Framework Core packages
dotnet add package Microsoft.EntityFrameworkCore
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
dotnet add package Microsoft.EntityFrameworkCore.Tools
# Restore the project to apply changes
dotnet restore