diff --git a/src/app/services/content-api.service.ts b/src/app/services/content-api.service.ts index cf4ca1847..d6a19b6fd 100644 --- a/src/app/services/content-api.service.ts +++ b/src/app/services/content-api.service.ts @@ -214,6 +214,10 @@ export class ContentApiService { return from(this.api.sharedLinksApi.findSharedLinks(opts)); } + getSharedLinkContent(sharedId: string, attachment?: boolean): string { + return this.api.contentApi.getSharedLinkContentUrl(sharedId, attachment); + } + search(request: SearchRequest): Observable { return from(this.api.searchApi.search(request)); } diff --git a/src/app/store/effects/download.effects.ts b/src/app/store/effects/download.effects.ts index cc58edc3b..d94651dc4 100644 --- a/src/app/store/effects/download.effects.ts +++ b/src/app/store/effects/download.effects.ts @@ -69,7 +69,7 @@ export class DownloadEffects { const { id, nodeId, name, isFile, isFolder } = node.entry; return { - id: nodeId || id, + id: this.isSharedLinkPreview ? id : nodeId || id, name, isFile, isFolder @@ -98,9 +98,16 @@ export class DownloadEffects { } private downloadFile(node: NodeInfo) { - if (node) { + if (node && !this.isSharedLinkPreview) { this.download(this.contentApi.getContentUrl(node.id, true), node.name); } + + if (node && this.isSharedLinkPreview) { + this.download( + this.contentApi.getSharedLinkContent(node.id, false), + node.name + ); + } } private downloadZip(nodes: Array) { @@ -130,4 +137,8 @@ export class DownloadEffects { document.body.removeChild(link); } } + + private get isSharedLinkPreview() { + return location.href.includes('/preview/s/'); + } }