Skip to content

Upload failures when using upload on click #42

Description

@zbremmer

I'm using dropzone in a flask application that uploads files to AWS S3. I have the following configuration for the dropzone:

app.config.update(
DROPZONE_MAX_FILES=10,
DROPZONE_PARALLEL_UPLOADS=3,
DROPZONE_UPLOAD_MULTIPLE=True,
DROPZONE_ALLOWED_FILE_CUSTOM=True,
DROPZONE_MAX_FILE_SIZE=10000,
DROPZONE_ALLOWED_FILE_TYPE=".xls, .xlsx, .csv, .doc, .rtf", 
DROPZONE_DEFAULT_MESSAGE="<br/><br/><br/>Drag files here or click to select",
DROPZONE_UPLOAD_ON_CLICK=True,
DROPZONE_UPLOAD_BTN_ID="upload_button",)

I notice that with this method, if a single file fails the upload (for ex, if the file is of the wrong type) none of the files are uploaded. The behavior that I would expect is that all of the other files continue to upload and only the single file that fails the file extension test does not upload. Below is the code for upload function in the flask application:

def upload():
    if request.method == "POST":
        
        for key, file in request.files.items():              
            if key.startswith('file'):                                               
                 
                # Save file locally                
                if not os.path.exists(tmp_folder_path):
                    os.mkdir(tmp_folder_path, 0o777)

                file.save(os.path.join(tmp_folder_path, file.filename))
                
    return render_template("index.html")

I'm using Python 3.7.4 with the following packages:

boto3==1.16.11
botocore==1.19.11
click==7.1.2
Flask==1.1.2
Flask-Dropzone==1.5.4
itsdangerous==1.1.0
Jinja2==2.11.2
jmespath==0.10.0
MarkupSafe==1.1.1
python-dateutil==2.8.1
s3transfer==0.3.3
six==1.15.0
urllib3==1.25.11
Werkzeug==1.0.1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions