Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BytesIO not work in client.files.upload #42

Open
OrganRemoved opened this issue Dec 21, 2024 · 0 comments
Open

BytesIO not work in client.files.upload #42

OrganRemoved opened this issue Dec 21, 2024 · 0 comments
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@OrganRemoved
Copy link

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Is this a client library issue or a product issue? We will only be able to assist with issues that pertain to the behaviors of this library. If the issue you're experiencing is due to the behavior of the product itself, please visit the Support page to reach the most relevant engineers.

If the support paths suggested above still do not result in a resolution, please provide the following details.

Environment details

  • Programming language: Python
  • OS: Windows 10 LTSC
  • Language runtime version: 3.12.8
  • Package version: 0.3.0

Steps to reproduce

  1. upload a image from a io.BytesIO object
    with BytesIO(image_data) as bio:
        client.files.upload(path=bio, config=types.UploadFileConfig(mime_type="image/jpeg"))
  2. Exception: TypeError: expected str, bytes or os.PathLike object, not BytesIO
    https://github.com/googleapis/python-genai/blob/main/google/genai/files.py#L850
    but the function signature show:
    Args:
          path: The path to the file or a file-like object (e.g. `BytesIO`) to be
            uploaded.
    
looks like it confuses `file-like` object and `path-like` object.

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

@OrganRemoved OrganRemoved added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

1 participant