[ACA-2284] Shared Link - Error when trying to download a shared file (#1026)

* shared link content download action

* use same action and effect

* call appropriate api baes on location

* remove unused property
This commit is contained in:
Cilibiu Bogdan
2019-03-21 16:29:13 +02:00
committed by Suzana Dirla
parent 8819f97de1
commit ba1c3c9e3b
2 changed files with 17 additions and 2 deletions

View File

@@ -214,6 +214,10 @@ export class ContentApiService {
return from(this.api.sharedLinksApi.findSharedLinks(opts)); return from(this.api.sharedLinksApi.findSharedLinks(opts));
} }
getSharedLinkContent(sharedId: string, attachment?: boolean): string {
return this.api.contentApi.getSharedLinkContentUrl(sharedId, attachment);
}
search(request: SearchRequest): Observable<ResultSetPaging> { search(request: SearchRequest): Observable<ResultSetPaging> {
return from(this.api.searchApi.search(request)); return from(this.api.searchApi.search(request));
} }

View File

@@ -69,7 +69,7 @@ export class DownloadEffects {
const { id, nodeId, name, isFile, isFolder } = <any>node.entry; const { id, nodeId, name, isFile, isFolder } = <any>node.entry;
return { return {
id: nodeId || id, id: this.isSharedLinkPreview ? id : nodeId || id,
name, name,
isFile, isFile,
isFolder isFolder
@@ -98,9 +98,16 @@ export class DownloadEffects {
} }
private downloadFile(node: NodeInfo) { private downloadFile(node: NodeInfo) {
if (node) { if (node && !this.isSharedLinkPreview) {
this.download(this.contentApi.getContentUrl(node.id, true), node.name); 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<NodeInfo>) { private downloadZip(nodes: Array<NodeInfo>) {
@@ -130,4 +137,8 @@ export class DownloadEffects {
document.body.removeChild(link); document.body.removeChild(link);
} }
} }
private get isSharedLinkPreview() {
return location.href.includes('/preview/s/');
}
} }