Esempio n. 1
0
def set_file_info(request):

    model_name, model_pk, filename = get_upload_identifiers_or_404(request)

    if not namespace_exists(model_name, model_pk):
        create_namespace(model_name, model_pk)

    resumable_file = get_or_create_resumable_file(model_name, model_pk, filename)

    resumable_file.filesize = int(request.POST['filesize'])
    resumable_file.save()
    return HttpResponse()
Esempio n. 2
0
def upload_file(request):

    model_name, model_pk, filename = get_upload_identifiers_or_404(request)

    if not namespace_exists(model_name, model_pk):
        create_namespace(model_name, model_pk)

    resumable_file = get_or_create_resumable_file(model_name, model_pk, filename)

    if request.method == 'POST' and request.FILES:
        # TODO: handle multiple files

        for _file in request.FILES:
            handle_uploaded_file(
                request.FILES[_file],
                request.POST.get('chunk', 0),
                resumable_file,
            )
        # response only to notify plUpload that the upload was successful
        return HttpResponse()
    else:
        return HttpResponseBadRequest