-1

I want to get the file size of the uploaded file without saving it on the disk. I am getting the file in controller like this

public async Task<IActionResult> GetIncomingFile(IFormFile file){
 // my code here
}
Fahad Subzwari
  • 2,109
  • 3
  • 24
  • 52

1 Answers1

2

You can use the Length property of the IFormFile object to get the file size. The Length property returns the size of the file in bytes.

Here is an example of how you can use it:

public async Task<IActionResult> GetIncomingFile(IFormFile file){
    long fileSize = file.Length;
    // Do something with the file size
    ...
}
Roman Marusyk
  • 23,328
  • 24
  • 73
  • 116