Skip to content

Commit

Permalink
remove s3 download
Browse files Browse the repository at this point in the history
  • Loading branch information
ozieblo-michal committed Jun 11, 2024
1 parent bffa2bc commit eb1e746
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
21 changes: 0 additions & 21 deletions src/backend/route/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,27 +81,6 @@ async def upload_to_s3(file: UploadFile = File(...)):

return {"message": "The file has been successfully uploaded to S3"}

@router.get("/download_s3/{filename}")
async def download_from_s3(filename: str):
bucket_name = os.getenv("S3_BUCKET_NAME")
file_name_in_s3 = "folder/" + filename

if os.getenv("USE_LOCALSTACK") == "true":
s3 = boto3.client(
"s3",
endpoint_url="http://localhost:4566",
region_name="us-east-1",
aws_access_key_id="test",
aws_secret_access_key="test",
)
else:
s3 = boto3.client("s3")

try:
s3.download_file(bucket_name, file_name_in_s3, f"downloads/{filename}")
return FileResponse(path=f"downloads/{filename}", filename=filename)
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))

@router.delete("/delete_from_s3/{filename}")
async def delete_from_s3(filename: str):
Expand Down
6 changes: 2 additions & 4 deletions src/frontend/my-app/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ function App() {
<h1>Simple Vite and FastAPI App</h1>
{!token && (
<h3 className="subtitle">
Enforce HTTPS is required for this site because it uses the default domain (ozieblo-michal.github.io). This may be disabled if you switch to a custom domain. Open the link <a href={`${backendUrl}:81`} target="_blank" rel="noopener noreferrer">{`${backendUrl}:81/docs`}</a> and accept the self-signed certificate to ensure the frontend functions correctly.
Enforce HTTPS is required for this site because it uses the default domain (ozieblo-michal.github.io). This may be disabled if you switch to a custom domain. Open the link <a href={`${backendUrl}`} target="_blank" rel="noopener noreferrer">{`${backendUrl}:81/docs`}</a> and accept the self-signed certificate to ensure the frontend functions correctly.
</h3>
)}
<div className="subtitle">
Expand Down Expand Up @@ -345,8 +345,6 @@ function App() {
)}
<div className="upload-buttons">
<input type="file" onChange={(e) => setSelectedFile(e.target.files[0])} />
</div>
<div className="upload-buttons">
<button className="upload-to-local" onClick={handleFileUpload}>Upload to Local</button>
<button className="upload-to-s3" onClick={handleFileUploadToS3}>Upload to S3</button>
</div>
Expand All @@ -368,7 +366,7 @@ function App() {
{s3Files.length > 0 ? (
s3Files.map((file, index) => (
<li key={index} className="file-item">
<a href={`${backendUrl}/download_s3/${file}`} target="_blank" rel="noopener noreferrer">{file}</a>
<span>{file}</span>
<button onClick={() => handleFileDeleteFromS3(file)}>Delete</button>
</li>
))
Expand Down

0 comments on commit eb1e746

Please sign in to comment.