-
Notifications
You must be signed in to change notification settings - Fork 838
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
How to upload multiple files within single call (using files.upload)? #442
Comments
files.upload
)?
files.upload
)?
Unfortunately at the moment, the https://api.slack.com/methods/files.upload endpoint only allows one file to be uploaded at once, meaning you have to iterate over your file list to make these multiple uploads through one api call for each. files = ['file1.jpg', 'file2.jpg']
for my_file in my_files:
response = client.files_upload(
channels='#random',
file=my_file)
assert response["ok"] This is just an example and not an Async one at that but it gives you an idea of how to implement this yourself. As for whether this is something Slack has available in the future, I don't know at the moment but absolutely something I'll let our team know of your interest in. |
Understand, that's how I implemented currently, by iterating and uploading files one by one. However, I wanted to see if I can decrease pressure on Slack API. |
Worth writing a async upload for the library that iterates over a list of files? Ive done something similar with asyncio.gather(**) before, differen't API. |
This may be a good option but we're not planning to implement it as part of this library. The straight-forward way to enable more efficient and quick ways to upload multiple files would be having another path to do that. I'll share this feedback with the teams concerned. Let me close this issue now. |
Any update on this, by chance? Is there any way to upload multiple files alongside one message? |
Still nope :( |
You cannot upload more than one file when the bot is called. Here is the tip: Just upload more than one files but you do not "display" it. Then take the response from the server with the URLs of the file uploaded, and "display" with markdown. I found this method in the link below: https://stackoverflow.com/questions/59939261/send-multiple-files-to-slack-via-api |
I've already accomplished that using the same stackoverflow document you used. But there should be some official way of doing it. Or atleast the documents should have some guidance about it. |
This doesn't seem to work anymore - permalinks formatted this way do not display as file previews. It's a pity, as there currently appears to be no way to construct a message sharing multiple images/other files unless they are public. |
@zpincus Sharing permalinks still should work as long as you pick up the right URLs. But we recently released a new way to upload files onto Slack: https://github.com/slackapi/python-slack-sdk/releases/tag/v3.19.0 With the files_upload_v2 method, you can upload multiple files at a time like humans do! |
Thanks! The new file upload method does the trick wonderfully. Strangely, I was never able to get any of the permalinks produced by I could make image galleries with links to public images just fine via posting a message consisting |
Description
I'm using
slackclient
v1 (because I need compatibility with Python 2).According to the
files.upload
documentation, when we uploading file usingfile
field it will load file content as amultipart/form-data
. However, I could not figure-out how to provide input for this parameter (through theapi_call
) when I want to upload multiple files at once?Is this even possible? If yes, documentation should be updated... If no, are there any plans to add this feature?
What type of issue is this?
The text was updated successfully, but these errors were encountered: