Enhance replication functionalilty
This commit is contained in:
15
app/ui.py
15
app/ui.py
@@ -703,10 +703,21 @@ def object_presign(bucket_name: str, object_key: str):
|
||||
_authorize_ui(principal, bucket_name, action, object_key=object_key)
|
||||
except IamError as exc:
|
||||
return jsonify({"error": str(exc)}), 403
|
||||
api_base = current_app.config["API_BASE_URL"].rstrip("/")
|
||||
|
||||
api_base = current_app.config.get("API_BASE_URL")
|
||||
if not api_base:
|
||||
api_base = "http://127.0.0.1:5000"
|
||||
api_base = api_base.rstrip("/")
|
||||
|
||||
url = f"{api_base}/presign/{bucket_name}/{object_key}"
|
||||
|
||||
headers = _api_headers()
|
||||
# Forward the host so the API knows the public URL
|
||||
headers["X-Forwarded-Host"] = request.host
|
||||
headers["X-Forwarded-Proto"] = request.scheme
|
||||
|
||||
try:
|
||||
response = requests.post(url, headers=_api_headers(), json=payload, timeout=5)
|
||||
response = requests.post(url, headers=headers, json=payload, timeout=5)
|
||||
except requests.RequestException as exc:
|
||||
return jsonify({"error": f"API unavailable: {exc}"}), 502
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user