Hi Lingaiah, as with everything C# there is a heap of different ways to upload and download files from an API. I've attached a zip file called FileController.zip which contains a single file FileController.cs. FileController.cs is a really basic example of how to upload and download a file from a SnapDevelop project. It was created in SnapDevelop 2019 R2. Just create a sample ASP.NET Core Web API application using the Basic sample code. If your application is called WebApplication1 then you can just drop the FileController.cs file into the Controllers directory and it should work. If your application is not called WebApplication1, just update this line in FileController.cs to replace WebApplication1 with the name of your application:
namespace WebApplication1.Controllers
The application will let you POST a file and save it to the attachments directory. You can then GET the file using the fileName GET argument.
e.g.
POST http://localhost:5000/api/file/upload
GET http://localhost:5000/api/file/download?fileName=testfile.pdf
The GET command you can just use from a browser. The POST command can be done from Postman, but it is probably just as easy to use curl. Here are the curl commands:
To upload:
curl -F uploadedFile=@testfile.pdf http://localhost:5000/api/file/upload
To download:
curl -G localhost:5000/api/file/download?filename=testfile.pdf --output testfile.pdf
This is a really basic example with no real error checking. The upload function just returns a HTTP 201 for a successful upload, but in real life I would probably have it return JSON with some data about the uploaded file (I would probably give it a unique filename and return that in the response). I would also probably send more data into the upload function with a multipart form. There is lots you can do with it, but hopefully this gives you some idea of where to start.