Class Files

java.lang.Object
com.google.genai.Files

public final class Files extends Object
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 Details

    • Files

      public Files(com.google.genai.ApiClient apiClient)
  • Method Details

    • get

      public File get(String name, GetFileConfig config)
      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

      public DeleteFileResponse delete(String name, DeleteFileConfig config)
      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

      public File upload(File file, UploadFileConfig config)
      Uploads a file to the API.
      Parameters:
      file - The file to upload.
      config - The configuration for the upload.
      Returns:
      The uploaded file.
    • upload

      public File upload(byte[] bytes, UploadFileConfig config)
      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

      public File upload(InputStream inputStream, long size, UploadFileConfig config)
      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

      public File upload(String filePath, UploadFileConfig config)
      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

      public void download(String fileName, String downloadPath, DownloadFileConfig config)
      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

      public void download(Video video, String downloadPath, DownloadFileConfig config)
      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

      public void download(File file, String downloadPath, DownloadFileConfig config)
      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

      public void download(GeneratedVideo generatedVideo, String downloadPath, DownloadFileConfig config)
      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

      public Pager<File> list(ListFilesConfig config)
      makes an API request to list the available files.
      Parameters:
      config - A ListFilesConfig 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.