-
Notifications
You must be signed in to change notification settings - Fork 836
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
Error 'no_file_data' in files_upload method when sending binary data in 'file' #728
Comments
@sofya-salmanova As a workaround, utilizing import logging
logging.basicConfig(level=logging.DEBUG)
from slack import WebClient
import os
client = WebClient(token=os.environ["SLACK_BOT_TOKEN"])
str = "This is a test"
bytes = bytearray(str, "utf-8")
# This doesn't work with 2.6.0+ as mentioned in this issue
res = client.files_upload(file=bytes, filename="test.txt", filetype="text")
# A workaround
import io
bio = io.BytesIO(bytes)
res = client.files_upload(file=bio, filename="test.txt", filetype="text") |
Fix #728 by adding bytearray support in files_upload (sync mode)
@seratch's workaround still required on 2.7.3. Is that expected? |
This issue is about sending a str = "This is a test"
bytes = bytearray(str, "utf-8")
# This doesn't work with 2.6.0+ as mentioned in this issue
res = client.files_upload(file=bytes, filename="test.txt", filetype="text") If you're facing a different issue, could you share code reproducing your issue? |
Oh my apologies, I'm dealing with the output of
And am seeing the same basic error:
|
@tplants thanks for reporting this! I confirmed the issue and will quickly fix it in the next release coming by the end of this week. |
Description
Error 'no_file_data' in files_upload method when sending binary data in 'file'
What type of issue is this? (place an
x
in one of the[ ]
)Requirements (place an
x
in each of the[ ]
)Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Reproducible in:
slackclient version: 2.6.0 and newer
python version: 3.6
OS version(s): Ubuntu 18.04.4
Steps to reproduce:
If I use version 2.5.0 (and earlier) -> bug is not reproduced
Setting file path into 'file' instead of bytes also fixes the problem, but I need to send files not saved on the disk, so this is not an acceptable alternative.
Expected result:
File is uploaded
Actual result:
error:
slack.errors.SlackApiError: The request to the Slack API failed.
The server responded with: {'ok': False, 'error': 'no_file_data'}
Attachments:
The text was updated successfully, but these errors were encountered: