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

files.upload's file param doesn't accept bytes data #770

Closed
4 of 9 tasks
seratch opened this issue Aug 5, 2020 · 2 comments · Fixed by #771
Closed
4 of 9 tasks

files.upload's file param doesn't accept bytes data #770

seratch opened this issue Aug 5, 2020 · 2 comments · Fixed by #771
Assignees
Labels
bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented Version: 2x web-client
Milestone

Comments

@seratch
Copy link
Member

seratch commented Aug 5, 2020

Description

Originally this is reported by @tplants at #728 (comment)

#730 resolved an issue with bytearray param but the change didn't support bytes properly.

# this is _bytes_ not a _bytearray_
file = io.BytesIO(bytes_like_object).getValue()

# This worked previously but does not work now.
res = client.files_upload(file=file, filename="test.xlsx", filetype="xlsx")

# This works now.
res = client.files_upload(file=io.BytesIO(file), filename="test.xlsx", filetype="xlsx")

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.
@seratch seratch added Version: 2x bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented web-client labels Aug 5, 2020
@seratch seratch added this to the 2.8.0 milestone Aug 5, 2020
@seratch seratch self-assigned this Aug 5, 2020
seratch added a commit to seratch/python-slack-sdk that referenced this issue Aug 5, 2020
@gburek-fastly
Copy link

After #771 was merged, the files_upload function signature still does not accept a bytes type object: https://github.com/slackapi/python-slack-sdk/blob/main/slack_sdk/web/client.py#L1458-L1460

    def files_upload(
        self, *, file: Union[str, IOBase] = None, content: str = None, **kwargs
    ) -> SlackResponse:

So the OP example produces a mypy error: Argument "file" to "files_upload" of "WebClient" has incompatible type "bytes"; expected "Union[str, IOBase, None]"

@seratch
Copy link
Member Author

seratch commented Dec 21, 2020

@gburek-fastly Thanks - I just created a new issue #901 for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented Version: 2x web-client
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants