Files API upload does not accept BytesIO or in-memory bytes
まだ誰も着手していません。
評価
調査の方向性
files_api.upload() の実装から始め、file 引数と options 引数がどのように処理されるかを追跡します。raw bytes、BytesIO、Django InMemoryUploadedFile、dict options を対象とした集中的なカバレッジを追加し、その後、アップロードで一時ファイルが不要になったことと、既存のファイル名の動作が維持されていることを確認します。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Python
- スター
- 434
- フォーク
- 126
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
HubSpot/hubspot-api-python のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
HubSpot/hubspot-api-python#497 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
HubSpot/hubspot-api-python#498 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
HubSpot/hubspot-api-python#496 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
HubSpot/hubspot-api-python#495 · コメント 1 件 · リアクション 2 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
HubSpot/hubspot-api-python#494 ·
HubSpot/hubspot-api-python の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
use-agent-os/agent-os#3314 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
BasedHardware/omi#15662 · コメント 1 件 ·
-
documentation help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
AiursoftWeb/AnduinOS-2#19 ·