Package com.microsoft.playwright.impl
Class DownloadImpl
- java.lang.Object
-
- com.microsoft.playwright.impl.DownloadImpl
-
-
Field Summary
Fields Modifier and Type Field Description private ArtifactImplartifactprivate com.google.gson.JsonObjectinitializerprivate PageImplpage
-
Constructor Summary
Constructors Constructor Description DownloadImpl(PageImpl page, ArtifactImpl artifact, com.google.gson.JsonObject initializer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel()Cancels a download.java.io.InputStreamcreateReadStream()Returns readable stream for current download ornullif download failed.voiddelete()Deletes the downloaded file.java.lang.Stringfailure()Returns download error if any.Pagepage()Get the page that the download belongs to.java.nio.file.Pathpath()Returns path to the downloaded file in case of successful download.voidsaveAs(java.nio.file.Path path)Copy the download to a user-specified path.java.lang.StringsuggestedFilename()Returns suggested filename for this download.java.lang.Stringurl()Returns downloaded url.
-
-
-
Field Detail
-
page
private final PageImpl page
-
artifact
private final ArtifactImpl artifact
-
initializer
private final com.google.gson.JsonObject initializer
-
-
Constructor Detail
-
DownloadImpl
DownloadImpl(PageImpl page, ArtifactImpl artifact, com.google.gson.JsonObject initializer)
-
-
Method Detail
-
url
public java.lang.String url()
Description copied from interface:DownloadReturns downloaded url.
-
suggestedFilename
public java.lang.String suggestedFilename()
Description copied from interface:DownloadReturns suggested filename for this download. It is typically computed by the browser from theContent-Dispositionresponse header or thedownloadattribute. See the spec on whatwg. Different browsers can use different logic for computing it.- Specified by:
suggestedFilenamein interfaceDownload
-
cancel
public void cancel()
Description copied from interface:DownloadCancels a download. Will not fail if the download is already finished or canceled. Upon successful cancellations,download.failure()would resolve to"canceled".
-
createReadStream
public java.io.InputStream createReadStream()
Description copied from interface:DownloadReturns readable stream for current download ornullif download failed.- Specified by:
createReadStreamin interfaceDownload
-
delete
public void delete()
Description copied from interface:DownloadDeletes the downloaded file. Will wait for the download to finish if necessary.
-
failure
public java.lang.String failure()
Description copied from interface:DownloadReturns download error if any. Will wait for the download to finish if necessary.
-
page
public Page page()
Description copied from interface:DownloadGet the page that the download belongs to.
-
path
public java.nio.file.Path path()
Description copied from interface:DownloadReturns 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.
-
saveAs
public void saveAs(java.nio.file.Path path)
Description copied from interface:DownloadCopy 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()));
-
-