I am trying to create a code to upload attachtment using ticket api. File uploaded do not have preview, when i download the files it can not be open.

here is the sample code:
with open(IMAGE_PATH, "rb") as image_file:
response = requests.post(
ZENDESK_UPLOAD_URL,
auth=AUTH,
files={"file": (IMAGE_NAME, image_file, "image/png")},
)
if response.status_code != 201:
print("❌ Upload failed:", response.status_code, response.text)
exit()
token = response.json()["upload"]["token"]
print("✅ Upload token:", token)
# === STEP 2: Create Ticket with Upload Token ===
ticket_data = {
"ticket": {
"subject": "🔥 Test ticket with image upload",
"comment": {
"body": "Here is the uploaded image from test script.",
"public": True,
"uploads": [token]
}
}
}
response = requests.post(
ZENDESK_TICKET_URL,
auth=AUTH,
headers={"Content-Type": "application/json"},
data=json.dumps(ticket_data)
)
if response.status_code == 201:
ticket_id = response.json()["ticket"]["id"]
print(f"✅ Ticket created! Ticket ID: {ticket_id}")
else:
print("❌ Failed to create ticket:", response.status_code, response.text)