Files API upload does not accept BytesIO or in-memory bytes

オープン
#459 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
api

調査の方向性

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 はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

HubSpot/hubspot-api-python のほかの issue

HubSpot/hubspot-api-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。