slack-ruby / slack-ruby-client

A Ruby and command-line client for the Slack Web, Real Time Messaging and Event APIs.
MIT License
1.19k stars 214 forks source link

chat post image #463

Closed MarioRuiz closed 1 year ago

MarioRuiz commented 1 year ago

Is there any way to send a chat post attached with an image, fex: image If I use send file endpoint then it is sent as a file so it is not displayed If I use the attachments parameter and include the image URL, it is displayed but then if the URL image is not available anymore then it is not displayed. I need this to be able to send images created using the OpenAI generated images and they are just live for one hour

duffn commented 1 year ago

If I use send file endpoint then it is sent as a file so it is not displayed

What do you mean not displayed? What is your code? The example in the README here works.

client.files_upload(
  channels: "#slack-ruby",
  file: Faraday::UploadIO.new("grogu.jpg", "image/jpeg"),
  title: "Grogu",
  filename: "grogu.jpg",
  initial_comment: "I like frogs."
)
Screen Shot 2023-04-01 at 12 54 13 PM
MarioRuiz commented 1 year ago

sending this code:

client.files_upload(
  channels: "#test-sm",
  file: Faraday::UploadIO.new("./tmp/rmario.jpg", "image/jpeg"),
  title: "Grogu",
  filename: "rmario.jpg",
  initial_comment: "I like frogs."
)

I get: image

rmario.jpg is only 197Kb

MarioRuiz commented 1 year ago

Ok I think I know why.... It seems like the file I am uploading has .jpg extension but in fact it is a png so Slack is not displaying it