From 205ca0da7e23a17cfe9e55288faa70fc5cedb6b0 Mon Sep 17 00:00:00 2001 From: lianbenjamin <79077248+lianbenjamin@users.noreply.github.com> Date: Thu, 19 Oct 2023 18:02:24 +0300 Subject: [PATCH] fix: add ks to image download request (#24) add ks to image request download url. --- src/services/download-service.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/services/download-service.ts b/src/services/download-service.ts index 91b1888..e48bf0f 100644 --- a/src/services/download-service.ts +++ b/src/services/download-service.ts @@ -56,7 +56,7 @@ class DownloadService { return null; } - const requestUrl = this.player.isImage() && this.player.sources.downloadUrl ? this.player.sources.downloadUrl : this.getDownloadUrl(config); + const requestUrl = this.getRequestUrl(config); if (!requestUrl) { return null; } @@ -83,6 +83,16 @@ class DownloadService { return null; } + getRequestUrl(config: DownloadConfig): string { + if (this.player.isImage()) { + const requestUrl = this.player.sources.downloadUrl; + if (!requestUrl) return ''; + const ks = this.player.config.session.ks; + return ks ? `${requestUrl}/ks/${ks}` : requestUrl; + } + return this.getDownloadUrl(config); + } + downloadFile(downloadUrl: string, fileName: string) { const aElement = document.createElement('a'); aElement.href = downloadUrl;