Flask-dropzone can't upload large files to firebase storage

139 Views Asked by At

is everything ok?

I am developing a project where in some page the user can upload a video. For this propose I've been using the flask-dropzone lib and getting success with pictures, but I can't upload big files, like videos. I've been studing how I can config this following the documentation, but without sucess until now.

I am trying to upload to firebase storage. Its working fine if I make the upload from the firebase console. Therefore I think it is a flask-dropzone issue. Have anybody any idea what's going on? Thank you so much^^

Dropzone Configs(main.py):

#--dropzone configs--#
app.config['DROPZONE_UPLOAD_MULTIPLE'] = False
app.config['DROPZONE_ALLOWED_FILE_CUSTOM'] = True
app.config['DROPZONE_ALLOWED_FILE_TYPE'] = 'video/*'
app.config['DROPZONE_MAX_FILE_SIZE'] = 50000
app.config['DROPZONE_REDIRECT_VIEW'] = 'edicaopadrao'
app.config['DROPZONE_UPLOAD_ON_CLICK'] = False

#the upload route
@app.route("/upload-principal", methods=['GET', 'POST'])
@login_required
def uploadprincipal():
    email = session['email']
    registro = {"usuario": email}
    if request.method == 'POST':
        for f in request.files.getlist('file'):
            print(str(f.content_type)[0:5])
            if str(f.content_type)[0:5] == 'video':
                arquivo = secure_filename(f.filename)
                arquivo2 = bucket.blob(arquivo)
                arquivo2.upload_from_file(f)
                arquivo2.make_public()
                session['video_upload'] = arquivo2.public_url
                registro[f'path: '] = arquivo2.public_url
                ref.child("Teste").push(registro)
    return render_template('upload-principal.html')

the page.html:

<head>
        <title>Flask App</title>
        {{ dropzone.load() }}
        {{ dropzone.style('border: 2px dashed #0087F7; margin: 10%; min-height: 400px;') }}
    </head>
    <body id="container-body">
      ...
        </div>
        <h1>Descarregue aqui os videos:</h1>
        {% include "includes/_message.html" %}
        {{ dropzone.create(action_view='uploadprincipal') }}
        {{ dropzone.config(max_file_size=5000) }}
    </body>

It might be a good idea to switch the flask-dropzone to dropzone cdn?

0

There are 0 best solutions below