Ajay98's picture
Update app.py
af94afd verified
raw
history blame
985 Bytes
from simple_salesforce import Salesforce
import requests
# Salesforce login
sf = Salesforce(username='your_username', password='your_password', security_token='your_security_token')
# URL of the image you want to download
url = 'https://ddl00000ao4u7uaj-dev-ed.develop.my.salesforce.com/sfc/dist/version/renditionDownload?rendition=ORIGINAL_Jpg&versionId=068dL000005Qu25&operationContext=DELIVERY&contentId=05TdL0000060xRF&page=0&d=/a/dL0000002yZZ/L_lC3MGQhWHNFIOXncHjmz6jw6D4fdTgCBu6'
# Adding session ID as authorization header to request the image
headers = {
'Authorization': 'Bearer ' + sf.session_id
}
# Sending a request to fetch the image
response = requests.get(url, headers=headers)
# Save the image if request is successful
if response.status_code == 200:
with open('john_image.jpg', 'wb') as f:
f.write(response.content)
print('Image downloaded successfully')
else:
print('Failed to download the image. Status code:', response.status_code)