mirror of
https://github.com/akuker/RASCSI.git
synced 2024-11-23 08:31:05 +00:00
Unzip and delete zip files after upload; validate upload file suffix
This commit is contained in:
parent
991d1232f9
commit
cda975a66f
@ -12,3 +12,4 @@ zope.event==4.5.0
|
||||
zope.interface==5.1.2
|
||||
protobuf==3.17.3
|
||||
pydrop==0.0.6
|
||||
zipfile
|
@ -180,6 +180,7 @@
|
||||
<script type="application/javascript">
|
||||
Dropzone.options.dropper = {
|
||||
paramName: 'file',
|
||||
acceptedFiles: '{{valid_file_suffix}}'
|
||||
chunking: true,
|
||||
forceChunking: true,
|
||||
url: '/files/upload',
|
||||
|
@ -526,6 +526,13 @@ def upload_file():
|
||||
log.debug(f"Chunk {current_chunk + 1} of {total_chunks} "
|
||||
f"for file {file.filename} completed.")
|
||||
|
||||
if file.filename.endswith("zip"):
|
||||
from zipfile import ZipFile
|
||||
with ZipFile(file_path, 'r') as zip:
|
||||
zip.extractall()
|
||||
delete_file(file_path)
|
||||
return make_response(("File upload and unzip successful!", 200))
|
||||
else:
|
||||
return make_response(("File upload successful!", 200))
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user