You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Files API upload does not accept BytesIO or in-memory bytes #459
In hubspot-api-client version 12.0.0, the files_api.upload() method fails when passing a file from memory, such as a BytesIO object, bytes, or a Django InMemoryUploadedFile. The SDK attempts to call open() on the object, leading to errors like:
TypeError: expected str, bytes or os.PathLike object, not _io.BytesIO
UnicodeDecodeError: 'utf-8' codec can't decode byte ...
TypeError: a bytes-like object is required, not 'dict'
The SDK should accept file-like objects or raw bytes and upload them to HubSpot.
Users should not be forced to write temporary files to disk.
Actual behavior
The SDK treats the object as a filename string, attempts open(), and raises a TypeError or UnicodeDecodeError.
Suggested fix
Update files_api.upload() to properly detect file-like objects (bytes, BytesIO, Django UploadedFile) and avoid always calling open(). Ensure options can be passed as a dict and converted to JSON internally, rather than requiring json.dumps
Activity
goran-revops commentedon Sep 23, 2026
Opened a pull request for this: #499