-1

I need an application that let users upload files to a public path where others can download it, but they are not allowed to upload a file that already exists. To check it faster i need to know the requested file's size and compare with file size of the others already uploaded files.

The problem:

file = request.files['file'] #returns FileStorage

And in the docs there is no reference to how get the file size. After using file.save(public_path_to_file) I can get the file size using os.stat(public_path_to_file).st_size. But before using save() I have not found a way to get the size of the incomming file.

Do you have any ideas?

strymsg
  • 11
  • 1
  • 3

1 Answers1

-3

You can do it by importing os. For example:

import os
sizeFile = os.stat('file.txt')
statinfo.st_size
Abdullah
  • 131
  • 1
  • 10