Skip to content

Commit 7c85c93

Browse files
authored
Merge pull request #68 from abolfazl8131/master
fix(download file): dedicate 2 file download routes
2 parents fa5e9ce + 8b9762a commit 7c85c93

14 files changed

+18
-5
lines changed
130 Bytes
Binary file not shown.
221 Bytes
Binary file not shown.
1.17 KB
Binary file not shown.
246 Bytes
Binary file not shown.
6.74 KB
Binary file not shown.
2.57 KB
Binary file not shown.
1.88 KB
Binary file not shown.

app/routes/utils.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,29 @@
44
import os
55

66

7-
@app.get("/download/{filename}")
8-
def download_file(filename: str):
9-
folder = "app/media/MyTerraform" # specify your folder path here
7+
@app.get("/download-helm/{filename}")
8+
def download_file_helm(filename: str):
9+
10+
folder = 'app/media/MyHelm'
1011
file_path = os.path.join(folder, filename)
12+
13+
if not os.path.isfile(file_path):
14+
raise HTTPException(status_code=404, detail="File not found.")
15+
16+
17+
return FileResponse(file_path, media_type='application/octet-stream', filename=filename)
18+
1119

12-
# Ensure the file exists
20+
@app.get("/download-terraform/{filename}")
21+
def download_file_terraform(filename: str):
22+
23+
folder = 'app/media/MyTerraform'
24+
file_path = os.path.join(folder, filename)
25+
1326
if not os.path.isfile(file_path):
1427
raise HTTPException(status_code=404, detail="File not found.")
1528

16-
# Return the file response for download
29+
1730
return FileResponse(file_path, media_type='application/octet-stream', filename=filename)
1831

1932
@app.get("/list-directory")
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)