-
Notifications
You must be signed in to change notification settings - Fork 125
Open
Description
Describe the bug
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'
To Reproduce
from io import BytesIO
import json
file_bytes = b"test content"
response = client.files.files_api.upload(
file=BytesIO(file_bytes),
file_name="test.txt",
folder_path="test",
options=json.dumps{"access": "PUBLIC_NOT_INDEXABLE"}
)Expected behavior
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
Metadata
Metadata
Assignees
Labels
No labels