@login_required
@require_POST
@xframe_options_sameorigin
def upload_async(request, media_type='image'):
    # TODO(paul): validate the Submit File on upload modal async
    #             even better, use JS validation for title length.
    try:
        if media_type == 'image':
            file_info = upload_image(request)
        else:
            msg = _(u'Unrecognized media type.')
            return HttpResponseBadRequest(
                json.dumps({'status': 'error', 'message': msg}))
    except FileTooLargeError as e:
        return HttpResponseBadRequest(
            json.dumps({'status': 'error', 'message': e.args[0]}))

    if isinstance(file_info, dict) and 'thumbnail_url' in file_info:
        schedule_rebuild_kb()
        return HttpResponse(
            json.dumps({'status': 'success', 'file': file_info}))

    message = _(u'Could not upload your image.')
    return HttpResponseBadRequest(
        json.dumps({'status': 'error',
                    'message': unicode(message),
                    'errors': file_info}))
Obtain a version from pkg_resources or setup-time logic if missing.
dataset/ETHPy150Open mozilla/kitsune/kitsune/gallery/views.py/upload_async--crossover with--dataset/ETHPy150Open blue-yonder/pyscaffold/pyscaffold/contrib/pbr/pbr/version.py/VersionInfo._get_version_from_pkg_resources