def get_file_from_request(ext=None, folder=None, name='file'):
 if (ext is None):
  ext = []
 print ('get_file_from_request() INVOKED. We have: request.files = %r' % request.files)
 if (name not in request.files):
  raise NotFoundError('File not found')
 uploaded_file = request.files[name]
 if (uploaded_file.filename == ''):
  raise NotFoundError('File not found')
 if (not _allowed_file(uploaded_file.filename, ext)):
  raise NotFoundError('Invalid file type')
 if (not folder):
  folder = app.config['UPLOAD_FOLDER']
 else:
  with app.app_context():
   folder = (app.config['BASE_DIR'] + folder)
 filename = secure_filename(uploaded_file.filename)
 uploaded_file.save(os.path.join(folder, filename))
 return os.path.join(folder, filename)

def get_file_from_request ( ext = None , folder = None , name = 'file' ) : if ( ext is None ) : ext = [ ] print ( 'get_file_from_request() INVOKED. We have: request.files = %r' % request . files ) if ( name not in request . files ) : raise NotFoundError ( 'File not found' ) uploaded_file = request . files [ name ] if ( uploaded_file . filename == '' ) : raise NotFoundError ( 'File not found' ) if ( not _allowed_file ( uploaded_file . filename , ext ) ) : raise NotFoundError ( 'Invalid file type' ) if ( not folder ) : folder = app . config [ 'UPLOAD_FOLDER' ] else : with app . app_context ( ) : folder = ( app . config [ 'BASE_DIR' ] + folder ) filename = secure_filename ( uploaded_file . filename ) uploaded_file . save ( os . path . join ( folder , filename ) ) return os . path . join ( folder , filename )
get file from a request .