flask request file upload to dropbox 1

flask request file upload to dropbox

@app.route('/uploadtest', methods=['POST', 'GET'])
def get_dropbox_files():
    if request.method == 'POST':
        uploadedfile = request.files['file']
        client = dbx_client
        f = secure_filename(uploadedfile.filename)
        path="/nameinlights/" + f
        dbx_client.files_upload(f.encode(), path)
        flash("Added" + " " + f + " " + "to Name in Lights Folder", 'success')

            
    return render_template('uploadtest.html', file_list=file_list)

Here is what the above code is Doing:
1. We’re importing the Dropbox SDK library and the os library.
2. We’re setting up a Dropbox client object.
3. We’re creating a function called get_dropbox_files().
4. We’re using the Dropbox client object to get a list of files in the app’s folder.
5. We’re returning a list of files to the template.
6. We’re rendering the template.

Similar Posts