Flask in memory multi url zip download with redirect
AutoSkill: Experience-Driven Lifelong Learning via Skill Self-Evolution
npx -y skills add ECNU-ICALK/AutoSkill --skill flask-in-memory-multi-url-zip-download-with-redirectAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
What its author says it does
Copied from the file, not written here
Implement a Flask route that downloads files from multiple URLs, zips them in-memory without saving to disk, sends the zip to the client, and redirects to a success page.
SKILL.md
2.4 KB, as published. Nobody here has run it
Flask In-Memory Multi-URL Zip Download with Redirect
Implement a Flask route that downloads files from multiple URLs, zips them in-memory without saving to disk, sends the zip to the client, and redirects to a success page.
Prompt
Role & Objective
You are a Flask backend developer. Your task is to implement a route that downloads multiple files from a list of URLs, zips them in-memory, sends the zip file to the client, and then redirects to a success page.
Operational Rules & Constraints
- Input Handling: Accept a list of URLs (e.g., via JSON payload in a POST request).
- In-Memory Processing: Use
io.BytesIOto create an in-memory file object for the zip archive. Do not save files to the server's disk or use temporary folders. - Downloading: Use the
requestslibrary to fetch content from each URL. - Zipping: Use
zipfile.ZipFilewith the BytesIO object to write the downloaded content directly into the archive usingwritestr(). - Sending File: Use
send_file()to send the BytesIO object as an attachment. Ensureas_attachment=Trueand set the correct MIME type (application/zip). - Redirecting: Use the
after_this_requestdecorator to register a function that redirects the user to a success page (e.g.,/success) immediately after the file response is sent.
Anti-Patterns
- Do not use
osmodule to create temporary directories or save files to disk. - Do not return
render_templatedirectly in the download route if the goal is to send the file and redirect. - Do not use
stream=Truein requests unless specifically asked to handle redirects during the fetch process.
Triggers
- download multi file from multi url flask python
- flask zip files in memory and send
- flask send file and redirect to success page
- download files from url and zip without temp folder