signal-cli-rest-api
signal-cli-rest-api copied to clipboard
Sending a image
The problem
Actual im trying this docker and try to send a json like this:
{ "message": "{{event}} \n{{subject}} \n{{message}} \n{{image}}", "number": "+0000", "recipients": [ "+000000" ] }
The image is a url to a JPG and it just shows the url and not the image. How to get the image shown in the message ?
Are you using the latest released version?
- [x] Yes
Have you read the troubleshooting page?
- [x] Yes
What type of installation are you running?
signal-cli-rest-api Docker Container
In which mode are you using the docker container?
Native Mode
What's the architecture of your host system?
x86-64
Additional information
No response
Do you add the base64 encoded image data to the JSON payload?
No the image is there ist just a url with a JPEG, so it needs to be a base64 ?
yeah, it needs to be base64 encoded.
I'm trying to figure out signal-cli-rest-api and it's taking a lot of time, I'm failing a lot, this is a new area for me. Therefore, I will try to write in the discussion everything that I succeeded and did not succeed, so that it would be easier for other people. Moreover, some of the official examples are non-working. In particular, I was unable to send a picture, as indicated in the example: https://github.com/bbernhard/signal-cli-rest-api/blob/master/doc/EXAMPLES.md Send a message with a base64 encoded attachment e.g: TMPFILE="$(base64 SignalsPictures/flow.png)" curl -X POST -H "Content-Type: application/json" -d '{"message": "Test image", "base64_attachments": ["' "${TMPFILE}"'"], "number": "+123456789012", "recipients": ["+123456789012"]}' 'http://localhost:8080/v2/send' Answer: "error":"Couldn't process request - invalid request"
I decided to send another file: TMPFILE="$(base64 SignalsPictures/1.jpg)" curl -X POST -H "Content-Type: application/json" -d '{"message": "Test image", "base64_attachments": ["'"$ {TMPFILE}"'"], "number": "+123456789012", "recipients": ["+123456789012"]}' 'http://localhost:8080/v2/send' Answer: /bin/sh: 47: curl: Argument list too long
Send a message (+ base64 encoded attachment) to multiple recipients
curl -X POST -H "Content-Type: application/json" -d '{"message": "
I thought the file must be encoded and found this question on Stackoverflows: https://stackoverflow.com/questions/75420538/base64-conversion-in-context-with-curl docker terminal
- base64 "SignalsPictures/flow.png" --wrap=0 > "1_crc.png"
- curl -X POST -H "Content-Type: application/json" -d '{"message": "Test image", "base64_attachments": ["1_crc.png"], "number": "+123456789012" , "recipients": ["+123456789012"]}' 'http://localhost:8080/v2/send' Answer: "error":"illegal base64 data at input byte 1"
I eventually found this discussion thread and tried sending the encoded file: TMPFILE="$(base64 1_crc.png)" && echo '{"message": "Test message", "base64_attachments": ["'"$TMPFILE"'"], "number": "+123456789012", "recipients ": ["+123456789012"]}' | curl -X POST -H "Content-Type: application/json" -d @- 'http://localhost:8080/v2/send' Answer: I received the file, but with the name 93a81d4a-...-f5e9613e18ce.txt and the value (content) of this file has been changed.
Thanks to user @UliEi, I was able to easily send an image to a group via Docker Terminal: TMPFILE="$(base64 SignalsPictures/flow.png)" && echo '{"message": "Test message", "base64_attachments": ["'"$TMPFILE"'"], "number": "+123456789012", "recipients": ["group.e..0="]}' | curl -X POST -H "Content-Type: application/json" -d @- 'http://localhost:8080/v2/send'
Forgive me for my French.