Package com.google.genai
Class AsyncFiles
java.lang.Object
com.google.genai.AsyncFiles
Async module of
Files
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondelete
(String name, DeleteFileConfig config) Asynchronously deletes a remotely stored file.download
(File file, String downloadPath, DownloadFileConfig config) Asynchronously downloads a file from the GenAI API to the provided path.download
(GeneratedVideo video, String downloadPath, DownloadFileConfig config) Asynchronously downloads a generated video from the GenAI API to the provided path.download
(Video video, String downloadPath, DownloadFileConfig config) Asynchronously downloads a video from the GenAI API to the provided path.download
(String fileName, String downloadPath, DownloadFileConfig config) Asynchronously downloads a file from the GenAI API to the provided path.get
(String name, GetFileConfig config) Asynchronously retrieves the file information from the service.list
(ListFilesConfig config) Asynchronously makes an API request to list the available files.upload
(byte[] bytes, UploadFileConfig config) Asynchronously uploads a bytes array as a file to the GenAI API.upload
(File file, UploadFileConfig config) Asynchronously uploads a file to the GenAI API.upload
(InputStream stream, long size, UploadFileConfig config) Asynchronously uploads a stream as a file to the GenAI API.upload
(String filePath, UploadFileConfig config) Asynchronously uploads a file by its path to the GenAI API.
-
Constructor Details
-
AsyncFiles
public AsyncFiles(com.google.genai.ApiClient apiClient)
-
-
Method Details
-
get
Asynchronously 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
Asynchronously 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
Asynchronously uploads a file to the GenAI API.- Parameters:
file
- The file to upload.config
- The configuration for the upload.- Returns:
- A future that resolves to the uploaded file.
-
upload
Asynchronously uploads a bytes array as a file to the GenAI API.- Parameters:
bytes
- The bytes of the file to upload.config
- The configuration for the upload.- Returns:
- A future that resolves to the uploaded file.
-
upload
Asynchronously uploads a stream as a file to the GenAI API.- Parameters:
stream
- The stream of the file to upload.size
- The size of the file in bytes.config
- The configuration for the upload.- Returns:
- A future that resolves to the uploaded file.
-
upload
Asynchronously uploads a file by its path to the GenAI API.- Parameters:
filePath
- The path to the file to upload.config
- The configuration for the upload.- Returns:
- A future that resolves to the uploaded file.
-
download
public CompletableFuture<Void> download(String fileName, String downloadPath, DownloadFileConfig config) Asynchronously downloads a file from the GenAI API to the provided path.- Parameters:
fileName
- The name of the file to download.downloadPath
- The path to download the file to.config
- The configuration for the download.- Returns:
- A future that resolves to the downloaded file.
-
download
public CompletableFuture<Void> download(Video video, String downloadPath, DownloadFileConfig config) Asynchronously downloads a video from the GenAI API to the provided path.- Parameters:
video
- The video to download.downloadPath
- The path to download the video to.config
- The configuration for the download.- Returns:
- A future that resolves to the downloaded video.
-
download
public CompletableFuture<Void> download(GeneratedVideo video, String downloadPath, DownloadFileConfig config) Asynchronously downloads a generated video from the GenAI API to the provided path.- Parameters:
video
- The generated video to download.downloadPath
- The path to download the video to.config
- The configuration for the download.- Returns:
- A future that resolves to the downloaded video.
-
download
Asynchronously downloads a file from the GenAI API to the provided path.- Parameters:
file
- The file to download.downloadPath
- The path to download the file to.config
- The configuration for the download.- Returns:
- A future that resolves to the downloaded file.
-
list
Asynchronously makes an API request to list the available files.- Parameters:
config
- AListFilesConfig
for configuring the list request.- Returns:
- A CompletableFuture that resolves to a
AsyncPager
. The AsyncPager has a `forEach` method that can be used to asynchronously process items in the page and automatically query the next page once the current page is exhausted.
-