google.generativeai.upload_file#

Calls the API to upload a file using a supported file service.

path

The path to the file or a file-like object (e.g., BytesIO) to be uploaded.

mime_type

The MIME type of the file. If not provided, it will be inferred from the file extension.

name

The name of the file in the destination (e.g., ‘files/sample-image’). If not provided, a system generated ID will be created.

display_name

Optional display name of the file.

resumable

Whether to use the resumable upload protocol. By default, this is enabled. See details at https://googleapis.github.io/google-api-python-client/docs/epy/googleapiclient.http.MediaFileUpload-class.html#resumable

file_types.File

The response of the uploaded file.