Exemplo n.º 1
0
def upload_image():
    """上传图片"""
    config = current_app.config
    try:
        filename = workimages.save(request.files['file'], name=random_filename() + ".")
        save_to_oss(filename, workimages)
    except Exception, err:
        return json.dumps({'status': 'no', 'error': err.__repr__()})
Exemplo n.º 2
0
def upload_image():
    """上传图片"""
    config = current_app.config
    try:
        filename = workimages.save(request.files['file'], name=random_filename() + ".")
        save_to_oss(filename, workimages)
    except Exception, err:
        return json.dumps({'status': 'no', 'error': err.__repr__()})
Exemplo n.º 3
0
def upload_image():
    """上传图片"""
    config = current_app.config
    try:
        filename = workimages.save(request.files['file'], name=random_filename() + ".")
        save_to_oss(filename, workimages)
    except Exception as err:
        return json.dumps({'status': 'no', 'error': err.__repr__()})
    else:
        return json.dumps({
            'status': 'yes',
            'filename': filename,
            'url': config.get('OSS_URL') + filename
        })
Exemplo n.º 4
0
def upload_image():
    """上传图片"""
    config = current_app.config
    try:
        filename = workimages.save(request.files['file'],
                                   name=random_filename() + ".")
        save_to_oss(filename, workimages)
    except Exception as err:
        return json.dumps({'status': 'no', 'error': err.__repr__()})
    else:
        return json.dumps({
            'status': 'yes',
            'filename': filename,
            'url': config.get('OSS_URL') + filename
        })