Here is the way I download my zip of excel files, with the zip file being created on-the-fly. In this example, the individual excel files reside in my AWS instance.
NOTE: This entire process must be achieved within 30 seconds if hosting on Heroku due to the web process time limit; unless you implement this asynchronously.
href assoc. with the button to invoke the download looks similar to the following:
Here is the code that handles the downloading of these files from my AWS instance, creating a zip to contain them, and then downloading to the user.
# Name of the zip file
filename = flask.request.args.get('filename')
# Num of files to process
num_files = flask.request.args.get('num_files')
# All files passed in via url string are of the format file_<filename>
files = 
for file in range(int(num_files)):
files.append(flask.request.args.get('file_' + str(file)))
# Loop thru files and add to zip
zip_buffer = io.BytesIO()
with zipfile.ZipFile(zip_buffer, "w", zipfile.ZIP_DEFLATED, False) as zip_file:
for file in files:
# aws.download is an internal function to download the file from my AWS S3 instance
file_obj = aws.download(file)
Here is the
# Download a file from the bucket
# Create connection to the bucket
s3_resource = boto3.resource('s3')
bucket = s3_resource.Bucket(S3_BUCKET)
# Return file object
Hope this helps and you can adapt to your needs.