0

I have a flask web app and after a long time run, I want to send an email with a download link to the zip file created and stored after the long time run. The zip file should be htpasswd protected. My ideas up to now:

  1. Create a zip file with the results and store it inside a folder in the flask app root

Question: How to set a htpasswd the zip file?

  1. Sent an email with flask-mail with the link and the password

  2. Delete the zip file after some time

How to check when a file needs to be deleted? My idea was to check with every newly submitted job, delete all jobs older than xy weeks.

JustAG33K
  • 1,403
  • 3
  • 13
  • 28
honeymoon
  • 2,400
  • 5
  • 34
  • 43

1 Answers1

0
with zipfile.ZipFile(memory_file, 'w') as zf:
    files = result['files']
    for individualFile in files:
        data = zipfile.ZipInfo(individualFile['fileName'])
        data.date_time = time.localtime(time.time())[:6]
        data.compress_type = zipfile.ZIP_DEFLATED
        zf.writestr(data, individualFile['fileData'])
memory_file.seek(0)
return send_file(memory_file, attachment_filename='capsule.zip', as_attachment=True)
pmadhu
  • 3,373
  • 2
  • 11
  • 23
  • Thanks but I want to sent a link to download the file per email and the zipfile should be htpasswd protected – honeymoon Oct 05 '21 at 11:43