Spaces:
Running
Running
Chandima Prabhath
commited on
Commit
·
87a21e8
1
Parent(s):
c424cee
Revert "Fix send_status_image to use correct key for uploaded file URL in response"
Browse filesThis reverts commit c424cee4fe6fc0effc786006d1b02046e4f1ab20.
app.py
CHANGED
@@ -146,13 +146,15 @@ def send_status_image(image_path, caption="Status Update", retries=3):
|
|
146 |
"""
|
147 |
# Step 1: Upload the image to get a file URL
|
148 |
upload_url = f"{GREEN_API_MEDIA_URL}/waInstance{GREEN_API_ID_INSTANCE}/uploadFile/{GREEN_API_TOKEN}"
|
|
|
149 |
try:
|
150 |
with open(image_path, "rb") as f:
|
151 |
files = {"file": f}
|
152 |
upload_response = requests.post(upload_url, files=files)
|
153 |
upload_response.raise_for_status()
|
154 |
upload_data = upload_response.json()
|
155 |
-
|
|
|
156 |
if not file_url:
|
157 |
logging.error("Upload failed: no file URL returned.")
|
158 |
return {"error": "No file URL returned from upload"}
|
|
|
146 |
"""
|
147 |
# Step 1: Upload the image to get a file URL
|
148 |
upload_url = f"{GREEN_API_MEDIA_URL}/waInstance{GREEN_API_ID_INSTANCE}/uploadFile/{GREEN_API_TOKEN}"
|
149 |
+
logging.debug("Uploading image to Green API: %s", upload_url)
|
150 |
try:
|
151 |
with open(image_path, "rb") as f:
|
152 |
files = {"file": f}
|
153 |
upload_response = requests.post(upload_url, files=files)
|
154 |
upload_response.raise_for_status()
|
155 |
upload_data = upload_response.json()
|
156 |
+
# Adjust key as per API response. Here we try "url" or "fileUrl".
|
157 |
+
file_url = upload_data.get("url") or upload_data.get("fileUrl")
|
158 |
if not file_url:
|
159 |
logging.error("Upload failed: no file URL returned.")
|
160 |
return {"error": "No file URL returned from upload"}
|