Skip to main content

Posting Images to Slack from Apache NiFi Using Custom Processor

Posting Images to Slack from Apache NiFi Using Custom Processor

As part of one of my remote camera feed projects, I wanted to send the images to Slack.

So I used my PostImage processor to send them via REST API.


It's a very simple flow.










PostImage Processor NAR Release
https://github.com/tspannhw/nifi-postimage-processor/releases/tag/1.1

Example Results

post.header
{X-Cache=[Miss from cloudfront], X-Accepted-OAuth-Scopes=[files:write:user,post], Server=[Apache], Access-Control-Allow-Origin=[*], X-Content-Type-Options=[nosniff], Connection=[keep-alive], Pragma=[no-cache], Date=[Mon, 11 Mar 2019 20:14:33 GMT], Access-Control-Allow-Headers=[slack-route, x-slack-version-ts], Via=[1.1 d0c5747a41ab1b19c48bdc3c7feed516.cloudfront.net (CloudFront)], Referrer-Policy=[no-referrer], Access-Control-Expose-Headers=[x-slack-req-id], Strict-Transport-Security=[max-age=31536000; includeSubDomains; preload], Cache-Control=[private, no-cache, no-store, must-revalidate], X-Via=[haproxy-www-ozs9], X-Slack-Req-Id=[7a42ad8f-bfcf-4b30-a3a6-7d38fb2b1e4a], X-Amz-Cf-Id=[Gr2gyXOdTmRLpTXssuFruYmk_D-487WBNdMtPzjlVj7SrLgsjLYXqw==], Vary=[Accept-Encoding], Expires=[Mon, 26 Jul 1997 05:00:00 GMT], X-XSS-Protection=[0], X-OAuth-Scopes=[identify,bot:basic], Content-Type=[application/json; charset=utf-8]}
post.results
{"file":{"filetype":"jpg","thumb_360":"https://files.slack.com/files-tmb/T1SD6MZMF-FGV6N568J-f7d3118d9a/2019-03-11_1547_360.jpg","thumb_160":"https://files.slack.com/files-tmb/T1SD6MZMF-FGV6N568J-f7d3118d9a/2019-03-11_1547_160.jpg","thumb_480":"https://files.slack.com/files-tmb/T1SD6MZMF-FGV6N568J-f7d3118d9a/2019-03-11_1547_480.jpg","title":"2019-03-11 1547","original_h":480,"ims":[],"mode":"hosted","shares":{"public":{"CGU6WRSNL":[{"channel_name":"images","reply_users":[],"reply_users_count":0,"team_id":"T1SD6MZMF","reply_count":0,"ts":"1552335275.020900"}]}},"image_exif_rotation":1,"url_private":"https://files.slack.com/files-pri/T1SD6MZMF-FGV6N568J/2019-03-11_1547.jpg","id":"FGV6N568J","display_as_bot":false,"timestamp":1552335273,"thumb_64":"https://files.slack.com/files-tmb/T1SD6MZMF-FGV6N568J-f7d3118d9a/2019-03-11_1547_64.jpg","thumb_80":"https://files.slack.com/files-tmb/T1SD6MZMF-FGV6N568J-f7d3118d9a/2019-03-11_1547_80.jpg","created":1552335273,"editable":false,"thumb_480_w":480,"is_external":false,"thumb_360_h":270,"groups":[],"pretty_type":"JPEG","external_type":"","url_private_download":"https://files.slack.com/files-pri/T1SD6MZMF-FGV6N568J/download/2019-03-11_1547.jpg","permalink_public":"https://slack-files.com/T1SD6MZMF-FGV6N568J-b58ce07115","is_starred":false,"size":367476,"channels":["CGU6WRSNL"],"comments_count":0,"name":"2019-03-11_1547.jpg","is_public":true,"thumb_360_w":360,"mimetype":"image/jpeg","public_url_shared":false,"permalink":"https://nifi-se.slack.com/files/UG2L4DSM9/FGV6N568J/2019-03-11_1547.jpg","user":"UG2L4DSM9","original_w":640,"username":"","thumb_480_h":360},"ok":true}
post.status
OK
post.statuscode
200