Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -99,10 +99,13 @@ def save_record_to_salesforce(annotated_image_url, coverage_percent, original_im
|
|
| 99 |
domain=os.environ.get('SF_DOMAIN', 'login') # 'test' for sandbox
|
| 100 |
)
|
| 101 |
|
| 102 |
-
#
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
compliance_status = 'Pass' if coverage_percent >= compliance_threshold else 'Fail'
|
| 108 |
technician_id = os.environ.get('SF_TECHNICIAN_ID') # Salesforce UserId lookup
|
|
@@ -113,7 +116,7 @@ def save_record_to_salesforce(annotated_image_url, coverage_percent, original_im
|
|
| 113 |
'Name': record_name,
|
| 114 |
'Annotated_Image__c': annotated_image_url,
|
| 115 |
'Coverage_Percentage__c': round(coverage_percent, 2),
|
| 116 |
-
'
|
| 117 |
'Compliance_Status__c': compliance_status,
|
| 118 |
'Technician_ID__c': technician_id,
|
| 119 |
'Verified_On__c': datetime.utcnow().isoformat()
|
|
|
|
| 99 |
domain=os.environ.get('SF_DOMAIN', 'login') # 'test' for sandbox
|
| 100 |
)
|
| 101 |
|
| 102 |
+
# Save original image temporarily, upload it, get URL
|
| 103 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".jpg") as temp_orig_img_file:
|
| 104 |
+
original_image_pil.save(temp_orig_img_file.name, format="JPEG")
|
| 105 |
+
temp_orig_img_path = temp_orig_img_file.name
|
| 106 |
+
|
| 107 |
+
original_image_url = upload_image_and_get_url(temp_orig_img_path)
|
| 108 |
+
os.unlink(temp_orig_img_path)
|
| 109 |
|
| 110 |
compliance_status = 'Pass' if coverage_percent >= compliance_threshold else 'Fail'
|
| 111 |
technician_id = os.environ.get('SF_TECHNICIAN_ID') # Salesforce UserId lookup
|
|
|
|
| 116 |
'Name': record_name,
|
| 117 |
'Annotated_Image__c': annotated_image_url,
|
| 118 |
'Coverage_Percentage__c': round(coverage_percent, 2),
|
| 119 |
+
'Original_Image_URL__c': original_image_url, # Changed to URL field instead of base64 text
|
| 120 |
'Compliance_Status__c': compliance_status,
|
| 121 |
'Technician_ID__c': technician_id,
|
| 122 |
'Verified_On__c': datetime.utcnow().isoformat()
|