helloflask / helloflask/flask-dropzone

Multiple File Upload and Server Side Validation

Open
#33 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
246
Forks
66
PR merge metrics
No merged PRs in 30d

Description

Hi @greyli ,
Awesome plugin. I am using it to upload multiple files along with some server-side validation. Is there a way to return the individual status of each uploaded file? It is clear how to do it when only one file is being uploaded from https://github.com/greyli/flask-dropzone/blob/master/docs/advanced.rst#server-side-validation

Here's a barebones implementation of what works so far. I currently just append all error messages with the corresponding filename:
```python
:
:
app.config['DROPZONE_UPLOAD_MULTIPLE'] = True
app.config['DROPZONE_MAX_FILE_SIZE'] = 10
app.config['DROPZONE_MAX_FILES'] = 5
app.config['DROPZONE_UPLOAD_ON_CLICK'] = True
:
:
@app.route('', methods=['GET', 'POST'])
def file_upload():
if request.method=='POST':
errors = []
for key, f in request.files.items():
if key.startswith('patent_file'):
filename = secure_filename(f.filename)
is_valid_file, msg, _, _ = validate_file(f, filename )
if not is_valid_file:
errors.append(filename + ' has error: ' + msg)
else:
f.save(os.path.join(app.config['UPLOADED_PATH'], patent_filename))
if len(errors)>0:
return ', '.join(errors), 400
return render_template('index.html')
```
This works. But it shows the same error message across all files. I am looking for a way to send individual status message per file. Is this achievable through the plugin? Thanks in advance.

Other details:
```bash
$ pip show flask_dropzone
Name: Flask-Dropzone
Version: 1.5.4
Summary: Upload file in Flask with Dropzone.js.
Home-page: https://github.com/greyli/flask-dropzone
Requires: Flask
Required-by:
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.