Downloading an archive created with mongodump Downloading an archive created with mongodump flask flask

Downloading an archive created with mongodump


So I've done it like this:

@api.route('/exportDB', methods=['GET'])def exportDB():    subprocess.check_output(['mongodump','--archive=db.gz', '--gzip', '--db', 'my_db'])    response = send_from_directory("path/to/folder", 'db.gz', as_attachment=True)    response.headers["Content-Type"] = "application/javascript"    return response

On client side I have:

$http({    method: 'GET',    url: '/intro/exportDB',    responseType: 'blob'}).then(function(response) {    var data = new Blob([response.data]);    saveAs(data, "db.gz"); }

Where saveAs is from Filesaver.js from here