mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-22 15:30:09 +00:00
Unzip and delete zip files after upload; validate upload file suffix
This commit is contained in:
parent
f336675f35
commit
d9bb875a27
@ -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,7 +526,14 @@ def upload_file():
|
||||
log.debug(f"Chunk {current_chunk + 1} of {total_chunks} "
|
||||
f"for file {file.filename} completed.")
|
||||
|
||||
return make_response(("File upload successful!", 200))
|
||||
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))
|
||||
|
||||
|
||||
@app.route("/files/create", methods=["POST"])
|
||||
|
Loading…
Reference in New Issue
Block a user