pythondjangofile-uploaddropzone.js

Django large file upload (.dcm)


After the user starts uploading files of 1-2 gb on a page in Django, I want the user to be able to navigate on other pages while the upload process continues. How can I do it?

I can upload the files to the server with the chunk method and merge them in the back. However, this upload process is interrupted when I switch to other pages. I want this to continue without interruption.

I tried to create a structure with Django channels and send files with the chunking method of dropzone.js, but I failed. Only string data was sent. I also could not convert the chunk .dcm data to base64.

I did not try the celery method. I just searched for its possibility, but I could not find anything clear.

autoProcessQueue: false,
url: url,
maxFiles: 100000000,
maxFilesize: 99999,
acceptedFiles: '.dcm',
timeout: 9999999999,
chunking: true,
chunkSize: 2000000,
clickable: "#dicomDropzone",
parallelChunkUploads: false,
retryChunks: true,
retryChunksLimit: 5,
forceChunking: true,
init: function() {  
    $('#CBCTUpload').click(function(){      
        myDropzone2.processQueue();
    })
    this.on("addedfile", function(file) {
        totalAddedFiles++;
    });
    this.on("sending", function(file, xhr, formData) {
        formData.append('slug', parametre);
    });
}


    if request.method == 'POST':
        if 'file' not in request.FILES:
            return HttpResponse(status=500)
        file = request.FILES['file']
        print("FILE", file.name)
        
        current_chunk = int(request.POST['dzchunkindex']) + 1
        total_chunks = int(request.POST['dztotalchunkcount'])
        dzchunkbyteoffset = int(request.POST['dzchunkbyteoffset'])
        folder_slug = request.POST.get('slug')

Solution

  • SPA (Single Page Application) using react or Angualr can help you in this but this can't be done in Django, as Django depends on request-response lifecycle especially if you are using Django templates.