Upload File in .net core
We are going to understand uploading using the Add Product method, we have a product controller and inside that we have an Add Product method.
First we will create a model for AddProduct and set Validation to properties
Add IFormFile Type in Model to get the file see above image.
Lets create AddProduct method and Use AddProduct Model
We can also configure Form option in Program.cs file
Run and upload the file using AddProduct API, File will be stored in uploads folder, Create folder before using this otherwise it will throw, we can auto create folder if not exists that code is not included here.
Create an api to download the file see below image.
Comments
Post a Comment