description: Calls the API to upload a file using a supported file service.
View source on GitHub |
Calls the API to upload a file using a supported file service.
google.generativeai.upload_file(
path: (str | pathlib.Path | os.PathLike),
*,
mime_type: (str | None) = None,
name: (str | None) = None,
display_name: (str | None) = None,
resumable: bool = True
) -> file_types.File
`path` | The path to the file 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. |