I have an API on my Flask server where I may upload a file from a client, using the following code:
@app.route('/api/uploadJob', methods = ['GET', 'POST'])
def uolpadJob():
try:
if request.method == 'POST':
f = request.files['file']
fullFilePath = os.path.join(app.config['UPLOAD_FOLDER'],
secure_filename(f.filename))
#fileSize = ???
f.save(fullFilePath)
I want to get the file size before to save it in my hard disk, so that I can compare it with the available disk space and chose if i want to save it or to return an error message. How can i get the file size before the actual upload?