1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #30422 -- Made TemporaryFileUploadHandler handle interrupted uploads.

This patch allows upload handlers to handle interrupted uploads.

Co-Authored-By: Mariusz Felisiak <felisiak.mariusz@gmail.com>
This commit is contained in:
aryan
2020-02-20 00:23:48 +05:30
committed by Mariusz Felisiak
parent 21b127bfbc
commit 11c4a4412b
7 changed files with 71 additions and 4 deletions

View File

@@ -2,6 +2,7 @@ import hashlib
import os
from django.core.files.uploadedfile import UploadedFile
from django.core.files.uploadhandler import TemporaryFileUploadHandler
from django.http import HttpResponse, HttpResponseServerError, JsonResponse
from .models import FileModel
@@ -112,6 +113,15 @@ def file_stop_upload_temporary_file(request):
)
def file_upload_interrupted_temporary_file(request):
request.upload_handlers.insert(0, TemporaryFileUploadHandler())
request.upload_handlers.pop(2)
request.FILES # Trigger file parsing.
return JsonResponse(
{'temp_path': request.upload_handlers[0].file.temporary_file_path()},
)
def file_upload_getlist_count(request):
"""
Check the .getlist() function to ensure we receive the correct number of files.