ios build update, about mih count fix & new get file api
This commit is contained in:
parent
7a5c8721dd
commit
62eafaf766
8 changed files with 236 additions and 371 deletions
|
|
@ -5,21 +5,21 @@ from dotenv import load_dotenv
|
|||
load_dotenv()
|
||||
minioAccess = os.getenv("MINIO_ACCESS_KEY")
|
||||
minioSecret = os.getenv("MINIO_SECRET_KEY")
|
||||
minioEndpoint = os.getenv("MINIO_ENDPOINT", "mih-minio:9000")
|
||||
minioSecure = os.getenv("MINIO_SECURE", "False") in ("True")
|
||||
|
||||
def minioConnect(env):
|
||||
if(env == "Dev"):
|
||||
return Minio(
|
||||
endpoint="mih-minio:9000",
|
||||
# "minio.mzansi-innovation-hub.co.za",
|
||||
endpoint=minioEndpoint,
|
||||
access_key=minioAccess,
|
||||
secret_key=minioSecret,
|
||||
secure=False
|
||||
secure=minioSecure,
|
||||
)
|
||||
else:
|
||||
return Minio(
|
||||
# endpoint="mih-minio:9000",
|
||||
endpoint="minio.mzansi-innovation-hub.co.za",
|
||||
endpoint=minioEndpoint,
|
||||
access_key=minioAccess,
|
||||
secret_key=minioSecret,
|
||||
secure=True
|
||||
)
|
||||
secure=minioSecure,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from typing import List
|
|||
import requests
|
||||
|
||||
from fastapi import APIRouter, HTTPException, File, UploadFile, Form
|
||||
from fastapi.responses import FileResponse, JSONResponse
|
||||
from fastapi.responses import FileResponse, JSONResponse, StreamingResponse
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
|
@ -108,6 +108,26 @@ class claimStatementUploud(BaseModel):
|
|||
logo_path: str
|
||||
sig_path: str
|
||||
|
||||
@router.get("/v2/minio/pull/file/{env}/{app_id}/{folder}/{file_name}", tags=["Minio"])
|
||||
async def pullFileFromMinioV2(app_id: str, folder: str, file_name: str, env: str):
|
||||
object_path = f"{app_id}/{folder}/{file_name}"
|
||||
try:
|
||||
client = Minio_Storage.minioConnection.minioConnect(env)
|
||||
|
||||
response = client.get_object(bucket_name="mih", object_name=object_path)
|
||||
|
||||
ext = file_name.split(".")[-1].lower()
|
||||
content_type = f"image/{ext}" if ext in ["png", "jpg", "jpeg", "gif", "webp"] else "application/octet-stream"
|
||||
|
||||
return StreamingResponse(
|
||||
io.BytesIO(response.read()),
|
||||
media_type=content_type,
|
||||
headers={"Cache-Control": "public, max-age=31536000"}
|
||||
)
|
||||
|
||||
except Exception as error:
|
||||
raise HTTPException(status_code=404, detail=f"File not found or MinIO connection failed: {str(error)}")
|
||||
|
||||
@router.get("/minio/pull/file/{env}/{app_id}/{folder}/{file_name}", tags=["Minio"])
|
||||
async def pull_File_from_user(app_id: str, folder: str, file_name: str, env: str): #, session: SessionContainer = Depends(verify_session())
|
||||
path = app_id + "/" + folder + "/" + file_name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue