1

我想在 ModelView 上获取一个文件,这是一个 flask-appbbuilder 类。我有这些模型:

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

而这些观点:

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

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

所以,我的问题是,我怎样才能获取并阅读上传的文件以在帖子中以 Aula 形式执行我的操作?

谢谢。

4

1 回答 1

0

您可以像这样构造文件的路径

self.appbuilder.app.config['UPLOAD_FOLDER'] + filename
于 2016-06-10T02:22:09.760 回答