DownloadTarget 编辑
A DownloadTarget
object represents the target of a download, for example a file in the global downloads directory, or a file in the system temporary directory.
Method overview
Promise refresh() |
Properties
Attribute | Type | Description |
exists Read only | Boolean | Indicates whether or not the target file exists. This is a dynamic property, which is updated when the download is completed or when the Download.refresh() method is called. You can use this instead of using file system calls to check for the existence of the file in order to reduce IO overhead. |
path Read only | string | The path of the target file. |
partFilePath Read only | string | The path of the ".part " file containing the data downloaded so far, or null to disable the use of a ".part " file to keep partially downloaded data. |
size Read only | Number | The size of the target file, in bytes, or zero if the download has not yet been completed. It is possible for this property to have a non-zero value even if the target file no longer exists, if the value is available in download metadata. If that metadata is no longer available and the file has been deleted, then this value is zero. For single-file downloads, this property's value will always match the actual size of the file on disk, while the For downloads of multiple files, such as downloading a web page and its required media to disk, the meaning of this property is undefined. It currently indicates the size of the main file (such as the HTML document) rather than the sum of all of the files' sizes, but you must not rely upon this behavior, as it is subject to change. This is a dynamic property, which is updated when the download finishes or whenever the |
Methods
refresh()
Updates the state of a finished, failed, or canceled download based on the current state as indicated by the file system. If the download is in progress or has been finalized, this method does nothing and returns a resolved Promise.
Calling this method lets the Download
object's properties be updated if the user moves or deletes the target file or its associated ".part" file, which contains a partially-downloaded file's contents.
Promise refresh();
Parameters
None.
Promise resolves to
undefined
when the state of the download has been updated.
Promise can be rejected with
Never.
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论