示例#1
0
def upload():
    file = request.files['file']

    if not file or not media_allowed_file(file.filename):
        raise Exception('file type not allowed!')

    upload_media(file)

    return_url = url_for('.index')
    return redirect(return_url)
示例#2
0
def upload(tip_id):
    file = request.files['file']
    tip = current_app.mongodb.Tip.find_one_by_id(tip_id)

    if not tip or not file or not media_allowed_file(file.filename):
        raise Exception('file upload not allowed!')

    media = upload_media(file)
    res_url = current_app.config.get('RES_URL')
    tip['src'] = u'{}/{}'.format(res_url, media['key'])
    tip.save()

    return_url = url_for('.detail', tip_id=tip['_id'])
    return redirect(return_url)
示例#3
0
def upload(promo_id):
    file = request.files['file']
    promotion = current_app.mongodb.Promotion.find_one_by_id(promo_id)

    if not promotion or not file or not media_allowed_file(file.filename):
        raise Exception('file upload not allowed!')

    media = upload_media(file)
    res_url = current_app.config.get('RES_URL')
    promotion['poster'] = u'{}/{}'.format(res_url, media['key'])
    promotion.save()

    return_url = url_for('.detail', promo_id=promotion['_id'])
    return redirect(return_url)
示例#4
0
def upload(activity_id):
    file = request.files['file']
    activity = current_app.mongodb.Activity.find_one_by_id(activity_id)

    if not activity or not file or not media_allowed_file(file.filename):
        raise Exception('file upload not allowed!')

    media = upload_media(file)
    res_url = current_app.config.get('RES_URL')
    activity['poster'] = u'{}/{}'.format(res_url, media['key'])
    activity.save()

    return_url = url_for('.detail', activity_id=activity['_id'])
    return redirect(return_url)