Ejemplo n.º 1
0
    def create(self, picture: Picture):
        connection = MySQLdb.connect(host="mysql.zuplae.com",
                                     user="******",
                                     passwd="lend4s",
                                     database="zuplae15")
        cursor = connection.cursor()
        cursor.execute(
            f"INSERT INTO FOTO (CONTEUDO, DESCRICAO, DATA_CRIACAO) VALUES('{picture.conteudo}','{ picture.descri}','{ picture.date_create}')"
        )
        picture.id = cursor.lastrowid
        connection.commit()
        connection.close()

        return picture.__dict__
Ejemplo n.º 2
0
    def post(self):
        parse = reqparse.RequestParser()
        parse.add_argument("image", type=FileStorage, location="files")
        args = parse.parse_args()
        picture = PictureDB()
        picture.id = str(uuid.uuid4())
        picture.id_property = request.form.get("id_property")
        picture.title = request.form.get("title")
        picture.subtitle = request.form.get("subtitle")
        picture.description = request.form.get("description")
        picture.blob_identifier = DriveHelper().upload_file(
            args.get("image").stream,
            args.get("image").content_type,
            args.get("image").filename)
        picture.order = request.form.get("order")
        picture.year = request.form.get("year")
        db.session.add(picture)
        db.session.commit()

        return {"message": "Picture saved", "data": picture.id}, 200