Class DownloadImpl

java.lang.Object
com.microsoft.playwright.impl.DownloadImpl
All Implemented Interfaces:
Download

class DownloadImpl extends Object implements Download
  • Field Details

    • page

      private final PageImpl page
    • artifact

      private final ArtifactImpl artifact
    • initializer

      private final com.google.gson.JsonObject initializer
  • Constructor Details

    • DownloadImpl

      DownloadImpl(PageImpl page, ArtifactImpl artifact, com.google.gson.JsonObject initializer)
  • Method Details

    • url

      public String url()
      Description copied from interface: Download
      Returns downloaded url.
      Specified by:
      url in interface Download
    • suggestedFilename

      public String suggestedFilename()
      Description copied from interface: Download
      Returns suggested filename for this download. It is typically computed by the browser from the Content-Disposition response header or the download attribute. See the spec on whatwg. Different browsers can use different logic for computing it.
      Specified by:
      suggestedFilename in interface Download
    • cancel

      public void cancel()
      Description copied from interface: Download
      Cancels a download. Will not fail if the download is already finished or canceled. Upon successful cancellations, download.failure() would resolve to "canceled".
      Specified by:
      cancel in interface Download
    • createReadStream

      public InputStream createReadStream()
      Description copied from interface: Download
      Returns readable stream for current download or null if download failed.
      Specified by:
      createReadStream in interface Download
    • delete

      public void delete()
      Description copied from interface: Download
      Deletes the downloaded file. Will wait for the download to finish if necessary.
      Specified by:
      delete in interface Download
    • failure

      public String failure()
      Description copied from interface: Download
      Returns download error if any. Will wait for the download to finish if necessary.
      Specified by:
      failure in interface Download
    • page

      public Page page()
      Description copied from interface: Download
      Get the page that the download belongs to.
      Specified by:
      page in interface Download
    • path

      public Path path()
      Description copied from interface: Download
      Returns path to the downloaded file in case of successful download. The method will wait for the download to finish if necessary. The method throws when connected remotely.

      Note that the download's file name is a random GUID, use Download.suggestedFilename() to get suggested file name.

      Specified by:
      path in interface Download
    • saveAs

      public void saveAs(Path path)
      Description copied from interface: Download
      Copy the download to a user-specified path. It is safe to call this method while the download is still in progress. Will wait for the download to finish if necessary.

      **Usage**

      
       download.saveAs(Paths.get("/path/to/save/at/", download.suggestedFilename()));
       
      Specified by:
      saveAs in interface Download
      Parameters:
      path - Path where the download should be copied.