Files API upload does not accept BytesIO or in-memory bytes
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start at the files_api.upload() implementation and trace how the file and options arguments are handled. Add focused coverage for raw bytes, BytesIO, Django InMemoryUploadedFile, and dict options, then verify uploads no longer require temporary files and the existing filename behavior remains intact.
Written by the indexing model from the issue text.
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
- Dominant language
- Python
- Stars
- 434
- Forks
- 126
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from HubSpot/hubspot-api-python
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
HubSpot/hubspot-api-python#497 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
HubSpot/hubspot-api-python#498 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
HubSpot/hubspot-api-python#496 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
HubSpot/hubspot-api-python#495 · 1 comment · 2 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
HubSpot/hubspot-api-python#494 ·
All issues in HubSpot/hubspot-api-python
Similar issues
-
bug confirmed issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
open-webui/open-webui#30750 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 90/100