google-gemini / generative-ai-python

The official Python library for the Google Gemini API
https://pypi.org/project/google-generativeai/
Apache License 2.0
1.62k stars 322 forks source link

Stream file upload #556

Closed Hamza-nabil closed 1 month ago

Hamza-nabil commented 2 months ago

Description of the change

Add support for streaming file uploads in the upload_file function.

The table below outlines the expected behavior for handling IOBase instances compared to Path instances: Feature For IOBase instance For Path instance
Upload Method MediaIoBaseUpload MediaFileUpload
Default MIME Type 'application/octet-stream' (reference here) MIME type is guessed based on the file extension
Default Display Name None path.name

Motivation

This update addresses #537, which requests the addition of support for uploading files via stream

Type of change

Feature request

Checklist

MarkDaoust commented 1 month ago

LGTM Thank you!

7b2c5ef

Oops, thanks for the fix!