Closed solanha1999 closed 3 years ago
SDK doesn't have an method to download a file.
In message incomming in your respond messages function (driver.respondToMessages(your_func)
) you can debug the message object. When an message with files/attachments are incomming, you can download this.
The method for download can require auth or no, depends on your server config here: Administration / File Upload / Protect Uploaded Files
.
Sample of message with attachment in livechat room:
{
_id: '6xQ2YNjyS7FpHEMKq',
rid: 'udDGmoWCZcYB3he9k',
msg: '',
token: 'kl1b2chq5od5jiuex8yaca',
file: {
_id: 'PRF4xNaWqKr9nEM5z',
name: 'Peek 12-07-2021 16-19.gif',
type: 'image/gif'
},
attachments: [
{
ts: '1970-01-01T00:00:00.000Z',
title: 'Peek 12-07-2021 16-19.gif',
title_link: '/file-upload/PRF4xNaWqKr9nEM5z/Peek%2012-07-2021%2016-19.gif',
title_link_download: true,
image_dimensions: [Object],
image_preview: 'xxxxxx',
image_url: '/file-upload/PRF4xNaWqKr9nEM5z/Peek%2012-07-2021%2016-19.gif',
image_type: 'image/gif',
image_size: 128576,
type: 'file'
}
],
alias: 'felipe-livechat',
ts: { '$date': 1626210620347 },
u: {
_id: 'rWQGzKyaomF2STaoL',
username: 'guest-2',
name: 'felipe-livechat'
},
_updatedAt: { '$date': 1626210620383 },
urls: [],
mentions: [],
channels: []
}
I hope this has helped you
Thanks again @felipetomm
I would like to know if there is a way to download files (or audios) sent by someone else in rocket chat? I would also like to know how could I identify the message type? (audio, file or text)
Thanks in advance!