Пример #1
0
    def create(self, request):
        case_guid = request.POST.get('procedure_guid', None)
        element_id = request.POST.get('element_id', None)
        element_type = request.POST.get('element_type', None)
        binary_guid = request.POST.get('binary_guid', None)
        file_size = request.POST.get('file_size', None)
        byte_start = request.POST.get('byte_start', None)
        byte_end = request.POST.get('byte_end', None)
        byte_data = request.POST.get('byte_data', None)

        # This hack submits byte_data as base64 encoded, so decode it.
        byte_data = byte_data.decode('base64')

        result, message = api.register_binary_chunk(case_guid,
                                                    element_id,
                                                    element_type,
                                                    binary_guid,
                                                    file_size,
                                                    byte_start,
                                                    byte_end,
                                                    [byte_data,])
        if result:
            response = succeed(message)
            logging.info("Successfully saved text-binary chunk: %s" % message)
        else:
            response = fail("Failed to save the text-binary chunk: %s" % message)
            logging.error("Failed to save text-binary chunk: %s" % message)
        return response
Пример #2
0
    def create(self, request):
        case_guid = request.POST.get('procedure_guid', None)
        element_id = request.POST.get('element_id', None)
        element_type = request.POST.get('element_type', None)
        binary_guid = request.POST.get('binary_guid', None)
        file_size = request.POST.get('file_size', None)
        byte_start = request.POST.get('byte_start', None)
        byte_end = request.POST.get('byte_end', None)
        byte_data = request.FILES.get('byte_data', None)

        result, message = api.register_binary_chunk(case_guid,
                                                    element_id,
                                                    element_type,
                                                    binary_guid,
                                                    file_size,
                                                    byte_start,
                                                    byte_end,
                                                    byte_data.chunks())
        if result:
            response = succeed(message)
            logging.info("Successfully saved binary chunk: %s" % message)
        else:
            response = fail("Failed to save the binary chunk: %s" % message)
            logging.error("Failed to save binary chunk: %s" % message)
        return response
Пример #3
0
    def create(self, request):
        case_guid = request.POST.get('procedure_guid', None)
        element_id = request.POST.get('element_id', None)
        element_type = request.POST.get('element_type', None)
        binary_guid = request.POST.get('binary_guid', None)
        file_size = request.POST.get('file_size', None)
        byte_start = request.POST.get('byte_start', None)
        byte_end = request.POST.get('byte_end', None)
        byte_data = request.POST.get('byte_data', None)

        # This hack submits byte_data as base64 encoded, so decode it.
        byte_data = byte_data.decode('base64')

        result, message = api.register_binary_chunk(case_guid, element_id,
                                                    element_type, binary_guid,
                                                    file_size, byte_start,
                                                    byte_end, [
                                                        byte_data,
                                                    ])
        if result:
            response = succeed(message)
            logging.info("Successfully saved text-binary chunk: %s" % message)
        else:
            response = fail("Failed to save the text-binary chunk: %s" %
                            message)
            logging.error("Failed to save text-binary chunk: %s" % message)
        return response
def binarychunk_submit(request):
    """Processes an individual chunk of binary data uploaded."""

    response = ''
    form = BinaryChunkSubmitForm(request.POST, request.FILES)

    if form.is_valid():
        logging.info("Received valid binarychunk form")

        procedure_guid = form.cleaned_data['procedure_guid']
        element_id = form.cleaned_data['element_id']
        element_type = form.cleaned_data['element_type']
        binary_guid = form.cleaned_data['binary_guid']
        file_size = form.cleaned_data['file_size']
        byte_start = form.cleaned_data['byte_start']
        byte_end = form.cleaned_data['byte_end']
        byte_data = form.cleaned_data['byte_data']

        try:
            result, message = register_binary_chunk(procedure_guid, element_id,
                                                    element_type, binary_guid,
                                                    file_size,
                                                    byte_start, byte_end,
                                                    byte_data.chunks())
            if result:
                response = json_succeed(
                    "Successfully saved the binary chunk: %s" % message)
            else:
                response = json_fail("Failed to save the binary chunk: %s" %
                                     message)
        except Exception, e:
            logging.error("registering binary chunk failed: %s" % e)
            response = json_fail("Registering binary chunk failed: %s" % e)
        logging.info("Finished processing binarychunk form")
Пример #5
0
    def create(self, request):
        case_guid = request.POST.get('procedure_guid', None)
        element_id = request.POST.get('element_id', None)
        element_type = request.POST.get('element_type', None)
        binary_guid = request.POST.get('binary_guid', None)
        file_size = request.POST.get('file_size', None)
        byte_start = request.POST.get('byte_start', None)
        byte_end = request.POST.get('byte_end', None)
        byte_data = request.FILES.get('byte_data', None)

        result, message = api.register_binary_chunk(case_guid, element_id,
                                                    element_type, binary_guid,
                                                    file_size,
                                                    byte_start, byte_end,
                                                    byte_data.chunks())
        if result:
            response = succeed(message)
            logging.info("Successfully saved binary chunk: %s" % message)
        else:
            response = fail("Failed to save the binary chunk: %s" % message)
            logging.error("Failed to save binary chunk: %s" % message)
        return response
Пример #6
0
def binarychunk_hack_submit(request):

    """Processes an individual chunk of binary data uploaded."""

    response = ''
    form = BinaryChunkHackSubmitForm(request.POST, request.FILES)

    if form.is_valid():
        logging.info("Received valid binarychunk-hack form")

        procedure_guid = form.cleaned_data['procedure_guid']
        element_id = form.cleaned_data['element_id']
        element_type = form.cleaned_data['element_type']
        binary_guid = form.cleaned_data['binary_guid']
        file_size = form.cleaned_data['file_size']
        byte_start = form.cleaned_data['byte_start']
        byte_end = form.cleaned_data['byte_end']
        byte_data = form.cleaned_data['byte_data']

        # This hack submits byte_data as base64 encoded, so decode it.
        byte_data = byte_data.decode('base64')

        try:
            result, message = register_binary_chunk(procedure_guid,
                                                    element_id,
                                                    element_type,
                                                    binary_guid,
                                                    file_size,
                                                    byte_start,
                                                    byte_end,
                                                    [byte_data,])
            if result:
                response = json_succeed("Successfully saved the binary chunk: %s" % message)
            else:
                response = json_fail("Failed to save the binary chunk: %s" % message)
        except Exception, e:
            logging.error("registering binary chunk failed: %s" % e)
            response = json_fail("Registering binary chunk failed: %s" % e)
        logging.info("Finished processing binarychunk form")