8

I'm using .net core web api to accept, upload and download the file content.

I've already tried IFormFile and simple base64 encoded file content

UploadFile(IFormFile file) UploadFile([FromBody] string base64Filecontentstring)

I'm just wondering if there is any difference in using any of those? If there is, which one should you use and when?

  • The two things are completely different, one is a binary upload and the other (I assume) requires the client to convert the file to Base64 first. – DavidG Jun 26 '19 at 14:08

1 Answers1

7

For small files Base64 will work fine, it's easy to handle and avoids dependency on Http.IFormFile in Domain.

But sending large files as Base64 using JSON is not a good idea. It will take a lot of memory & time for converting back to the actual image for copying on the Server.

I suggest the excellent article: https://medium.com/@ma1f/file-streaming-performance-in-dotnet-4dee608dd953 which shows that base64 performance is 5x-20x worse.

It's up to you.

Rafael Augusto
  • 355
  • 3
  • 9