示例#1
0
def start_transfer_api(request):
    """
    Endpoint for starting a transfer if calling remote and using an API key.
    """
    if request.method not in ('POST', ):
        return django.http.HttpResponseNotAllowed(['POST'])

    auth_error = authenticate_request(request)
    response = {}
    if auth_error is not None:
        response = {'message': auth_error, 'error': True}
        return django.http.HttpResponseForbidden(
            json.dumps(response), content_type='application/json')

    transfer_name = request.POST.get('name', '')
    transfer_type = request.POST.get('type', '')
    accession = request.POST.get('accession', '')
    # Note that the path may contain arbitrary, non-unicode characters,
    # and hence is POSTed to the server base64-encoded
    paths = request.POST.getlist('paths[]', [])
    paths = [base64.b64decode(path) for path in paths]
    row_ids = request.POST.getlist('row_ids[]', [''])

    response = filesystem_ajax_views.start_transfer(transfer_name,
                                                    transfer_type, accession,
                                                    paths, row_ids)
    return helpers.json_response(response)
示例#2
0
def start_transfer_api(request):
    """
    Endpoint for starting a transfer if calling remote and using an API key.
    """
    transfer_name = request.POST.get('name', '')
    transfer_type = request.POST.get('type', '')
    accession = request.POST.get('accession', '')
    # Note that the path may contain arbitrary, non-unicode characters,
    # and hence is POSTed to the server base64-encoded
    paths = request.POST.getlist('paths[]', [])
    paths = [base64.b64decode(path) for path in paths]
    row_ids = request.POST.getlist('row_ids[]', [''])

    response = filesystem_ajax_views.start_transfer(transfer_name,
                                                    transfer_type, accession,
                                                    paths, row_ids)
    return helpers.json_response(response)
示例#3
0
def start_transfer_api(request):
    """
    Endpoint for starting a transfer if calling remote and using an API key.
    """
    transfer_name = request.POST.get("name", "")
    transfer_type = request.POST.get("type", "")
    accession = request.POST.get("accession", "")
    access_id = request.POST.get("access_system_id", "")
    # Note that the path may contain arbitrary, non-unicode characters,
    # and hence is POSTed to the server base64-encoded
    paths = request.POST.getlist("paths[]", [])
    paths = [base64.b64decode(path) for path in paths]
    row_ids = request.POST.getlist("row_ids[]", [""])
    try:
        response = filesystem_ajax_views.start_transfer(
            transfer_name, transfer_type, accession, access_id, paths, row_ids)
        return helpers.json_response(response)
    except Exception as e:
        return _error_response(str(e), status_code=500)