Fix minio localhost public URL by proxying through backend
This commit is contained in:
@@ -1847,3 +1847,16 @@ def verify_payment(payload: VerifyPaymentPayload, session: Session = Depends(get
|
||||
return {"success": True, "tier": user.tier.value}
|
||||
|
||||
|
||||
|
||||
@app.get("/api/storage/{bucket}/{object_name:path}", tags=["Storage"])
|
||||
def get_storage_file(bucket: str, object_name: str):
|
||||
import storage
|
||||
import io
|
||||
from fastapi.responses import StreamingResponse
|
||||
file_bytes = storage.get_file(object_name)
|
||||
if not file_bytes:
|
||||
from fastapi import HTTPException
|
||||
raise HTTPException(status_code=404, detail="File not found")
|
||||
content_type = "application/pdf" if object_name.endswith(".pdf") else "application/octet-stream"
|
||||
return StreamingResponse(io.BytesIO(file_bytes), media_type=content_type)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user