RocketChat / hubot-rocketchat

Rocket.Chat Hubot adapter
MIT License
574 stars 227 forks source link

Upload files to Room #235

Open timgrossmann opened 7 years ago

timgrossmann commented 7 years ago

Hey,

I know that there is a feature to send "attachments" via Links #172 . But my question would be whether there is support to upload files like Images or Documents.

Thank you -- Tim

timkinnane commented 6 years ago

Hey @timgrossmann. You could use the API via the SDK included in the adapter. Similar to the example I provided here: https://github.com/RocketChat/hubot-rocketchat/issues/64#issuecomment-387097878 - but using the endpoint for the upload documented here: https://rocket.chat/docs/developer-guides/rest-api/rooms/upload/

So it's possible in a roundabout way. Hypothetically we could support this as a standard method, like robot.adapter.upload() the way a regular .send works but with a file upload attached - but it's a bit tricky and not often required, so if you can solve your own issue as suggested, I'll close this, unless you feel strongly it should be a feature, then I'm happy to tag it as such and leave it open to get attention some day.

OliverEvans96 commented 5 years ago

@timkinnane If I understand correctly, In the rocket.chat docs, they show examples with curl, and use the -F flag to post file data as Content-type: multipart/form-data in the post request. I haven't been able to figure out how to post file data from hubot's robot.http, which seems to use node-scoped-http-client to provide a DSL interface to node's http package. Is there a minimal working example you could point me to?

Thanks! Oliver

timkinnane commented 5 years ago

Hi @OliverEvans96 - I don't have a working example to point you at sorry. I'm not aware of anyone doing this, but if you find a solution please post it.

OliverEvans96 commented 5 years ago

Thanks @timkinnane ! I'll post an example here once I circle back to this project.