onDeterminingFilename property
During the filename determination process, extensions will be given the
opportunity to override the target DownloadItem.filename. Each
extension may not register more than one listener for this event. Each
listener must call suggest
exactly once, either
synchronously or asynchronously. If the listener calls
suggest
asynchronously, then it must return
true
. If the listener neither calls suggest
synchronously nor returns true
, then suggest
will be called automatically. The DownloadItem will not complete
until all listeners have called suggest
. Listeners may call
suggest
without any arguments in order to allow the download
to use downloadItem.filename
for its filename, or pass a
suggestion
object to suggest
in order to
override the target filename. If more than one extension overrides the
filename, then the last extension installed whose listener passes a
suggestion
object to suggest
wins. In order to
avoid confusion regarding which extension will win, users should not
install extensions that may conflict. If the download is initiated by
download and the target filename is known before the MIME type and
tentative filename have been determined, pass filename
to
download instead.
Implementation
EventStream<OnDeterminingFilenameEvent> get onDeterminingFilename =>
$js.chrome.downloads.onDeterminingFilename.asStream(($c) => (
$js.DownloadItem downloadItem,
$js.SuggestFilenameCallback suggest,
) {
return $c(OnDeterminingFilenameEvent(
downloadItem: DownloadItem.fromJS(downloadItem),
suggest: (FilenameSuggestion? suggestion) {
//ignore: avoid_dynamic_calls
(suggest as Function)(suggestion?.toJS);
},
));
}.toJS);