Spaces:
Running
Running
Chandima Prabhath
commited on
Commit
·
c424cee
1
Parent(s):
6c4cd05
Fix send_status_image to use correct key for uploaded file URL in response
Browse files
app.py
CHANGED
|
@@ -146,15 +146,13 @@ 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 |
-
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 |
-
|
| 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"}
|
|
|
|
| 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 |
+
file_url = upload_data.get("urlFile")
|
|
|
|
| 156 |
if not file_url:
|
| 157 |
logging.error("Upload failed: no file URL returned.")
|
| 158 |
return {"error": "No file URL returned from upload"}
|