More obscure links that lack clarity and cohesiveness
Attachments
As of version 3.0 of our iOS, Android, and Desktop apps, Pushover messages can include an image attachment. When received by a device, it will attempt to download the image and display it with the notification. If this fails or takes too long, the notification will be displayed without it and the image download can be retried inside the Pushover app. Note that, like messages, once attachments are downloaded by the device, they are deleted from our servers and only stored on the device going forward. Attachments uploaded for devices that are not running at least version 3.0 of our apps will be discarded as they cannot be displayed by those devices.
Attachment files must be directly sent to our API with your other message parameters and cannot be included as a URL or other parameter that would instruct our servers or the device clients to download the file. This is done for efficiency and for the privacy of our users to avoid making requests to non-Pushover URLs without their knowledge.
Each message may only include one attachment, and attachments are currently limited to 5,242,880 bytes (5.0 megabytes). Attempting to send attachments larger than this size will be rejected with an API error (or server error for extremely large file attempts). Any resizing of images to fit under this limit must be done on the sending side before making the API request.
Attachment data may be sent in two different ways. For HTTP clients and libraries supporting multipart/form-data
HTTP bodies, the attachment may be sent directly as binary data, including its content type in the parameter. See the Attachments - multipart/form-data section for instructions.
For HTTP clients that don’t support multipart/form-data
but where Base64 encoding is available, the attachment may instead be sent as the attachment_base64
parameter. See the Attachments - Base64 section for instructions.
Attachments - multipart/form-data
While all other API parameters may be sent using standard application/x-www-form-urlencoded
encoding (the default for most HTTP libraries), including an attachment this way requires sending parameters using multipart/form-data
encoding which not all HTTP libraries support. Consult the documentation for your library to see whether it supports this and how to send parameters using this encoding. If it is not supported, see the Base64 option.
Python with Image Attachment
To send an image attachment, the 3rd party Requests library can be used. For example, to send the file “your_image.jpg
”:
import requests r = requests.post(“https://api.pushover.net/1/messages.json”, data = { “token”: “APP_TOKEN”, “user”: “USER_KEY”, “message”: “hello world” }, files = { “attachment”: (“image.jpg”, open(“your_image.jpg”, “rb”), “image/jpeg”) }) print(r.text)