google.generativeai.upload_file#
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 | IOBase),
*,
mime_type: (str | None) = None,
name: (str | None) = None,
display_name: (str | None) = None,
resumable: bool = True
) -> file_types.File
Args | |
---|---|
The path to the file or a file-like object (e.g., BytesIO) to be uploaded. |
|
The MIME type of the file. If not provided, it will be inferred from the file extension. |
|
The name of the file in the destination (e.g., ‘files/sample-image’). If not provided, a system generated ID will be created. |
|
Optional display name of the file. |
|
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 |
Returns | |
---|---|
The response of the uploaded file. |