Rekham1110 commited on
Commit
0d21784
·
verified ·
1 Parent(s): 638a209

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -6,6 +6,7 @@ from simple_salesforce import Salesforce
6
  from datetime import datetime
7
  import hashlib
8
  import shutil
 
9
 
10
  # Load environment variables
11
  load_dotenv()
@@ -78,9 +79,9 @@ def process_image(image, project_name):
78
  saved_image_path = os.path.join(upload_dir, image_filename)
79
  shutil.copy(image, saved_image_path)
80
 
81
- # Read the file into binary format to upload to Salesforce
82
  with open(saved_image_path, 'rb') as image_file:
83
- image_data = image_file.read()
84
 
85
  # Create the ContentVersion record in Salesforce
86
  content_version = {
 
6
  from datetime import datetime
7
  import hashlib
8
  import shutil
9
+ import base64
10
 
11
  # Load environment variables
12
  load_dotenv()
 
79
  saved_image_path = os.path.join(upload_dir, image_filename)
80
  shutil.copy(image, saved_image_path)
81
 
82
+ # Convert image to base64 before uploading to Salesforce
83
  with open(saved_image_path, 'rb') as image_file:
84
+ image_data = base64.b64encode(image_file.read()).decode('utf-8')
85
 
86
  # Create the ContentVersion record in Salesforce
87
  content_version = {