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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user