I have the following model :
public class FileModel
{
public byte[] FileData{get;set;}
public string FileName {get;set;}
}
I have coded a private Web API service which my Web application consumes.
When the user uploads files, I convert those files to a byte array, and send a List<FileModel>
to my Web API from C# code (not from an HTML page, since my Web API is private from my website), which saves my file and return results.
Web API method:
[HttpPost]
public UploadFiles(List<FileModel> files)
{
// Do work
}
The above code breaks if I upload many large-sized files - the code failed to serialize the large files' FileModel
s since they exceed the max serializing length.
How do I fix this issue? Is there any other way to upload files to Web API without exposing it to the users?