Skip to content

Uploading avatar using BytesIO(bytes_object) fails without raising an exception #566

Description

@truenicoco

Summary

While it is possible to edit one's avatar using a file written on disk, it's not possible to pass a file-like buffer

Reproduction Steps

# bytes_ is a bytes object on len = 52718
await self.steam.user.edit(avatar=steam.Media(BytesIO(bytes_)))

Expected Results

Set my avatar on steam, or at least raise an exception if it fails.

Actual Results

It does not raise an exception, but this appears in the DEBUG logs:

DEBUG:steam.http:POST https://steamcommunity.com/actions/FileUploader with PAYLOAD: <aiohttp.formdata.FormData object at 0x7f2f275a5590> has returned 200
DEBUG:steam.http:POST https://steamcommunity.com/actions/FileUploader has received <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<title>Image Uploader</title>
<style type="text/css">
...
<body>
The file you tried to upload was too large.  Please upload a file smaller than 1,024KB.
<a href="?type=player_avatar_image&sId=76561198048913696&bgColor=000000&fgColor=ffffff">Try Again</a>
</body>
</html>

Writing the same bytes to a file on disk and passing the path to this file instead of the BytesIO object works as intended

System Information

python version: 3.11.2
steam.py version: 1.0.1
aiohttp version: 3.9.5
betterproto version: 2.0.0b6
operating system info: Linux-6.6.13+bpo-amd64-x86_64-with-glibc2.36

Checklist

  • I have searched the issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my username, password, shared/identity secrets and refresh/access tokens from display, if visible.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions