Private
Public Access
1
0

simple upload tests

This commit is contained in:
2025-10-22 12:31:36 +02:00
parent b6d8ec0429
commit 6ca40ad6ba
7 changed files with 236 additions and 331 deletions

View File

@@ -142,6 +142,16 @@ def handle_uploaded_image(i): # pragma: no cover
def handle_uploaded_file(f):
fname = f.name
if hasattr(f, 'temporary_file_path'):
file_path = f.temporary_file_path()
else:
import tempfile
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
for chunk in f.chunks():
temp_file.write(chunk)
file_path = temp_file.name
return fname, file_path
ext = fname.split('.')[-1]
fname = '%s.%s' % (uuid.uuid4(), ext)
fname2 = 'media/'+fname