Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative way to assign image attachments to a channel? #161

Open
alexmacarthur opened this issue Nov 26, 2024 · 1 comment
Open

Alternative way to assign image attachments to a channel? #161

alexmacarthur opened this issue Nov 26, 2024 · 1 comment

Comments

@alexmacarthur
Copy link

As far as I can tell, the only way to assign an attachment to a channel is using the “file” property, which is the CDN URL. Those URLs are signed, and so I’m concerned about them expiring after 14 days, and the images would no longer be viewable in the channel. Is this true? Or is there another way to upload attachments to avoid this issue?

image

This does not seem to be the same way you can upload attachments in the Node SDK. There, you can pass attachments directly, which would give me a little more confidence.

const promises = [
  channel.sendImage(
    fs.createReadStream('./cat.png'),
    'cat.jpg',
    'cat/jpg',
    {id: "some-user"}
  ),
 ];
 
 const results = await Promise.all(promises);
 const attachments = results.map(response => {
   return {
     type: 'image',
     thumb_url: response.file,
     asset_url: response.file,
   };
 });

 const response = await channel.sendMessage({
   text: 'I have uploaded things.',
   attachments,
   user
 });
@shaljam
Copy link
Contributor

shaljam commented Nov 29, 2024

Hi @alexmacarthur ,
The attachment URLs will be refreshed if needed when being fetched. See here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants