Package com.microsoft.playwright.impl
Class DownloadImpl
java.lang.Object
com.microsoft.playwright.impl.DownloadImpl
- All Implemented Interfaces:
Download
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ArtifactImplprivate final com.google.gson.JsonObjectprivate final PageImpl -
Constructor Summary
ConstructorsConstructorDescriptionDownloadImpl(PageImpl page, ArtifactImpl artifact, com.google.gson.JsonObject initializer) -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Cancels a download.Returns readable stream for current download ornullif download failed.voiddelete()Deletes the downloaded file.failure()Returns download error if any.page()Get the page that the download belongs to.path()Returns path to the downloaded file in case of successful download.voidCopy the download to a user-specified path.Returns suggested filename for this download.url()Returns downloaded url.
-
Field Details
-
page
-
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
Description copied from interface:DownloadReturns downloaded url. -
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
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
Description copied from interface:DownloadReturns download error if any. Will wait for the download to finish if necessary. -
page
Description copied from interface:DownloadGet the page that the download belongs to. -
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
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()));
-