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

Uploading a file with a message #94

Open
camuthig opened this issue Jul 2, 2020 · 5 comments
Open

Uploading a file with a message #94

camuthig opened this issue Jul 2, 2020 · 5 comments

Comments

@camuthig
Copy link

camuthig commented Jul 2, 2020

I recently needed to implement a new feature where I uploaded a CSV file to Slack along with a the message I was sending. I was not able to implement this using django-slack natively, so had to access the files.upload Slack API directly instead. I haven't yet thought of a clean way to do it, but what are your thoughts on providing some sort of support for file uploads in this project?

@lamby
Copy link
Owner

lamby commented Jul 2, 2020

The API docs are here: https://api.slack.com/methods/files.upload

No strong feelings about how this should be done, but looks like it will need a new top-level method we export publically in api.py. What do you think? Will probably have to abstract out a bunch of config handling...

@camuthig
Copy link
Author

camuthig commented Jul 3, 2020

My initial thought was that it would need to be a new top-level method as well, but wasn't certain. For a first implementation, I think you could leave it up to the developer to create the content of the upload, rather than use file. I only did some basic testing, but using content worked well for me right out of the box with the default backend, at least.

Fields that would be fairly easy and could work with logic already present in the existing templates are:

  • initial_comment (just text of a message)
  • token can come from the existing settings
  • channels could use the existing channel with just a bit of tweaking

Otherwise, the only new fields I think you need are

  • filename
  • filetype
  • title

@lamby
Copy link
Owner

lamby commented Jul 3, 2020

Cool, thanks for your input - really useful. (Just to let you know though - I don't have the ability to prioritise this volunteer work right now around my other work and stuff.)

@camuthig
Copy link
Author

camuthig commented Jul 3, 2020

Not a problem. I have a working implementation on my side for specifically what I need. If I come across some time, I'll see if I can work through a PR for you as well.

@lamby
Copy link
Owner

lamby commented Jul 3, 2020

If you could paste your code here that would be good, even without any other context or even if it's broken - will provide a good place to start. 👍

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