1

I want to fetch a file on ModelView, a flask-appbbuilder class. I have these models:

class Professor(User):
    pass

class Aula(Model):
    id = Column(Integer, primary_key=True)
    professor_id = Column(Integer, ForeignKey('ab_user.id'), nullable=False)
    professor = relationship('Professor')
    conteudo = Column(String(200), nullable=False)
    data_aula = Column(DateTime, nullable=False)
    arquivo = Column(FileColumn()) # <-- **this file**
   #arquivo_path = Column(String(255), nullable=True)

    def __repr__(self):
        return self.data_aula

And these views:

class AulaModelView(ModelView):
    datamodel = SQLAInterface(Aula)
    related_views = [PerguntaModelView]

class ProfessorModelView(ModelView):
    datamodel = SQLAInterface(Professor)
    related_views = [AulaModelView]

So, my question is, how can I get and read the uploaded file to do my actions in Aula form in post?

Thanks.

Kross
  • 303
  • 1
  • 4
  • 14

1 Answers1

0

You can construct the path to the file like this

self.appbuilder.app.config['UPLOAD_FOLDER'] + filename
Remi Guan
  • 21,506
  • 17
  • 64
  • 87
dpgaspar
  • 1,193
  • 8
  • 10