[Solved] Send message to channel with local file attachment

Hi All,

I am new to Mattermost. I have configured MatterMost open source (docker compose) and able to login and chat. I am also able to send messages to Channel using curl. Now I want to send attach pdf file to message from local folder in message (currently testing using curl, will be using python after POC). I checked docs and was able to send image using image_url and also add link to header. But I want to attach local generated file to message.

Was unable to find any sample parameter for file attachment / example, which helps me achieve this.

It would be really helpful if anyone can guide me on how i can do this.

Thanks

I was able to achieve this by doing following steps:

  1. upload file to channel with: curl -i -X POST -H “Authorization: Bearer accesstoken” -F “channel_id=MMChannelId” -F “files=@path/file.pdf”

  2. curl -i -X POST -H “Authorization: Bearer token” -H “Content-Type: application/json” -d “{\“channel_id\”: \“channelid\”,\“message\”: \“Here’s the latest data :newspaper:\”,\“file_ids\”: [\“id from above comand\”]}”

2 Likes

Nice work figuring it out, Atul!