Package com.google.genai
Class Files
java.lang.Object
com.google.genai.Files
Provides methods for interacting with the available GenAI files. Instantiating this class is not
required. After instantiating a
Client
, access methods through
`client.files.methodName(...)` directly.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondelete
(String name, DeleteFileConfig config) Deletes a remotely stored file.void
download
(File file, String downloadPath, DownloadFileConfig config) Downloads a file from the API.void
download
(GeneratedVideo generatedVideo, String downloadPath, DownloadFileConfig config) Downloads a generated video from the API.void
download
(Video video, String downloadPath, DownloadFileConfig config) Downloads a video from the API.void
download
(String fileName, String downloadPath, DownloadFileConfig config) Downloads a file from the API.get
(String name, GetFileConfig config) Retrieves the file information from the service.list
(ListFilesConfig config) makes an API request to list the available files.upload
(byte[] bytes, UploadFileConfig config) Uploads a file to the API.upload
(File file, UploadFileConfig config) Uploads a file to the API.upload
(InputStream inputStream, long size, UploadFileConfig config) Uploads a file to the API.upload
(String filePath, UploadFileConfig config) Uploads a file to the API.
-
Constructor Details
-
Files
public Files(com.google.genai.ApiClient apiClient)
-
-
Method Details
-
get
Retrieves the file information from the service.- Parameters:
name
- - The name identifier for the file to retrieve.config
- - Optional, configuration for the get method.- Returns:
- A File object representing the file.
-
delete
Deletes a remotely stored file.- Parameters:
name
- - The name identifier for the file to delete.config
- - Optional, configuration for the delete method.- Returns:
- The DeleteFileResponse, the response for the delete method.
-
upload
Uploads a file to the API.- Parameters:
file
- The file to upload.config
- The configuration for the upload.- Returns:
- The uploaded file.
-
upload
Uploads a file to the API.- Parameters:
bytes
- The bytes of the file to upload.config
- The configuration for the upload.- Returns:
- The uploaded file.
-
upload
Uploads a file to the API.- Parameters:
inputStream
- The input stream of the file to upload.size
- The size of the file to upload.config
- The configuration for the upload.- Returns:
- The uploaded file.
-
upload
Uploads a file to the API.- Parameters:
filePath
- The path of the file to upload.config
- The configuration for the upload.- Returns:
- The uploaded file.
-
download
Downloads a file from the API.- Parameters:
fileName
- The name of the file to download.downloadPath
- The path to download the file to.config
- The configuration for the download.
-
download
Downloads a video from the API.- Parameters:
video
- The video to download.downloadPath
- The path to download the video to.config
- The configuration for the download.
-
download
Downloads a file from the API.- Parameters:
file
- The file to download.downloadPath
- The path to download the file to.config
- The configuration for the download.
-
download
Downloads a generated video from the API.- Parameters:
generatedVideo
- The generated video to download.downloadPath
- The path to download the generated video to.config
- The configuration for the download.
-
list
makes an API request to list the available files.- Parameters:
config
- AListFilesConfig
for configuring the list request.- Returns:
- A
Pager
object that contains the list of files. The pager is an iterable and automatically queries the next page once the current page is exhausted.
-