Merge pull request #18216 from Snuffleupagus/download-data
Change `DownloadManager.download` to use Uint8Array-data
This commit is contained in:
commit
593ce96834
10
web/app.js
10
web/app.js
@ -1083,13 +1083,11 @@ const PDFViewerApplication = {
|
|||||||
this._ensureDownloadComplete();
|
this._ensureDownloadComplete();
|
||||||
|
|
||||||
const data = await this.pdfDocument.getData();
|
const data = await this.pdfDocument.getData();
|
||||||
const blob = new Blob([data], { type: "application/pdf" });
|
this.downloadManager.download(data, url, filename, options);
|
||||||
|
|
||||||
await this.downloadManager.download(blob, url, filename, options);
|
|
||||||
} catch {
|
} catch {
|
||||||
// When the PDF document isn't ready, or the PDF file is still
|
// When the PDF document isn't ready, or the PDF file is still
|
||||||
// downloading, simply download using the URL.
|
// downloading, simply download using the URL.
|
||||||
await this.downloadManager.downloadUrl(url, filename, options);
|
this.downloadManager.downloadUrl(url, filename, options);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1106,9 +1104,7 @@ const PDFViewerApplication = {
|
|||||||
this._ensureDownloadComplete();
|
this._ensureDownloadComplete();
|
||||||
|
|
||||||
const data = await this.pdfDocument.saveDocument();
|
const data = await this.pdfDocument.saveDocument();
|
||||||
const blob = new Blob([data], { type: "application/pdf" });
|
this.downloadManager.download(data, url, filename, options);
|
||||||
|
|
||||||
await this.downloadManager.download(blob, url, filename, options);
|
|
||||||
} catch (reason) {
|
} catch (reason) {
|
||||||
// When the PDF document isn't ready, or the PDF file is still
|
// When the PDF document isn't ready, or the PDF file is still
|
||||||
// downloading, simply fallback to a "regular" download.
|
// downloading, simply fallback to a "regular" download.
|
||||||
|
|||||||
@ -113,8 +113,10 @@ class DownloadManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
download(blob, url, filename, _options) {
|
download(data, url, filename, _options) {
|
||||||
const blobUrl = URL.createObjectURL(blob);
|
const blobUrl = URL.createObjectURL(
|
||||||
|
new Blob([data], { type: "application/pdf" })
|
||||||
|
);
|
||||||
download(blobUrl, filename);
|
download(blobUrl, filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -140,8 +140,10 @@ class DownloadManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
download(blob, url, filename, options = {}) {
|
download(data, url, filename, options = {}) {
|
||||||
const blobUrl = URL.createObjectURL(blob);
|
const blobUrl = URL.createObjectURL(
|
||||||
|
new Blob([data], { type: "application/pdf" })
|
||||||
|
);
|
||||||
|
|
||||||
FirefoxCom.request("download", {
|
FirefoxCom.request("download", {
|
||||||
blobUrl,
|
blobUrl,
|
||||||
|
|||||||
@ -160,12 +160,12 @@ class IDownloadManager {
|
|||||||
openOrDownloadData(data, filename, dest = null) {}
|
openOrDownloadData(data, filename, dest = null) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Blob} blob
|
* @param {Uint8Array} data
|
||||||
* @param {string} url
|
* @param {string} url
|
||||||
* @param {string} filename
|
* @param {string} filename
|
||||||
* @param {Object} [options]
|
* @param {Object} [options]
|
||||||
*/
|
*/
|
||||||
download(blob, url, filename, options) {}
|
download(data, url, filename, options) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user