downloads.show()

La fonction show() de l'API downloads affiche le fichier téléchargé dans son dossier contenant dans le gestionnaire de fichiers de la plate-forme sous-jacente.

C'est une fonction asynchrone qui renvoie une Promise.

Syntaxe

js
var showing = browser.downloads.show(
  downloadId, // integer
);

Paramètes

downloadId

Un integer représentant l'ID du DownloadItem à afficher.

Valeur retournée

Une Promise. Si la demande est acceptée, la promise sera remplie avec un booléen indiquant si la demande a été acceptée. Si la demande échoue, la promise sera rejetée avec un message d'erreur.

Compatibilité des navigateurs

Exemples

Cet exemple montre l'élément le plus récemment téléchargé :

js
function onShowing(success) {
  console.log(`Showing download item: ${success}`);
}

function onError(error) {
  console.log(`Error opening item: ${error}`);
}

function openDownload(downloadItems) {
  if (downloadItems.length > 0) {
    latestDownloadId = downloadItems[0].id;
    var showing = browser.downloads.show(latestDownloadId);
    showing.then(onShowing, onError);
  }
}

var searching = browser.downloads.search({
  limit: 1,
  orderBy: ["-startTime"],
});

searching.then(openDownload, onError);

Note :

Cette API est basée sur l'API Chromium chrome.downloads.

Les données de compatibilité relatives à Microsoft Edge sont fournies par Microsoft Corporation et incluses ici sous la licence Creative Commons Attribution 3.0 pour les États-Unis.