コード例 #1
0
def upload():
    body = json.loads(request.data)
    image_data = body.get("image_data")
    if not image_data:
        return failure_response("Missing image")
    asset = Asset(image_data = image_data)
    db.session.add(asset)
    db.session.commit()
    return success_response(asset.serialize(), 201)
コード例 #2
0
ファイル: app.py プロジェクト: danielorourke/Ithaca-Trails
def upload():
    body = json.loads(request.data)
    image_data = body.get("image_data")
    if image_data is None:
        return failure_response("No base64 URL to be found")

    asset = Asset(image_data=image_data)
    db.session.add(asset)
    db.session.commit()
    return success_response(asset.serialize(), 201)
コード例 #3
0
def uploadImage(imageData, imgType, typeId):
    asset = Asset(image_data=imageData, img_type=imgType, type_id=typeId)
    if asset is None:
        return None
    db.session.add(asset)
    if imgType == "profile":
        user = User.query.filter_by(id=typeId).first()
        user.photo.append(asset)
    elif imgType == "post":
        post = Post.query.filter_by(id=typeId).first()
        post.photos.append(asset)
    db.session.commit()
    return asset.serialize()
コード例 #4
0
def upload_picture(user_id):
    body = json.loads(request.data)
    username = body.get("username")
    password = body.get("password")
    if username is None or password is None:
        return failure_response("Invalid username or password")
    was_successful, user = users_dao.verify_credentials(username, password)
    if not was_successful:
        return failure_response("Incorrect username or password")
    image_data = body.get("image_data")
    if (image_data is None):
        return failure_response("No base64 image")
    asset = Asset(image_data=image_data)
    db.session.add(asset)
    db.session.commit()
    return success_response(asset.serialize())