From 1e22fed54e016eabca9e14ee54089f380c45b61a Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Mon, 29 Nov 2021 16:17:52 +0100 Subject: [PATCH] =?UTF-8?q?OZG-1614=20Bearer=20Token=20zur=20Download=20UR?= =?UTF-8?q?L=20hinzuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ozg-file/ozg-file.component.ts | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/goofy-client/libs/ozg-file/src/lib/ozg-file-container/ozg-file/ozg-file.component.ts b/goofy-client/libs/ozg-file/src/lib/ozg-file-container/ozg-file/ozg-file.component.ts index a33a903ed7..fd4897bb6f 100644 --- a/goofy-client/libs/ozg-file/src/lib/ozg-file-container/ozg-file/ozg-file.component.ts +++ b/goofy-client/libs/ozg-file/src/lib/ozg-file-container/ozg-file/ozg-file.component.ts @@ -1,4 +1,6 @@ import { Component, EventEmitter, Input, Output } from '@angular/core'; +import { HttpParams } from '@angular/common/http'; +import { OAuthService } from 'angular-oauth2-oidc'; import { OzgFileLinkRel, OzgFileResource } from '@goofy-client/ozg-file-shared'; import { createEmptyStateResource, StateResource } from '@goofy-client/tech-shared'; import { getUrl, hasLink } from '@ngxp/rest'; @@ -20,6 +22,8 @@ export class OzgFileComponent { @Output() public startDownload: EventEmitter<OzgFileResource> = new EventEmitter<OzgFileResource>(); @Output() public startDelete: EventEmitter<OzgFileResource> = new EventEmitter<OzgFileResource>(); + constructor(private authService: OAuthService) {} + get isDisabled(): boolean { return this.getStateResource().loading; } @@ -37,13 +41,16 @@ export class OzgFileComponent { } dragStart(event) { - if (!!this.file.contentType || this.file.contentType === '') this.file.contentType = 'application/octet-stream'; - const downloadUrl = `${ this.file.contentType }:${ this.file.name }:${ getUrl(this.file, OzgFileLinkRel.DOWNLOAD)}` - //const downloadUrl = `${ this.file.contentType }:${ this.file.name }:${ getUrl(this.file, OzgFileLinkRel.DOWNLOAD)}` - //const downloadUrl = 'image/jpeg:Helge1.jpg:http://localhost:4300/api/ozgfiledata/13f009e2-8c81-4d69-9502-b99af959b14f' - //const downloadUrl = 'application/pdf:test-dnd.pdf:http://localhost:4300/assets/test-dnd.pdf' - //const downloadUrl = 'image/jpeg:Helge1.jpg:http://localhost:4300/assets/Helge1.jpg' - console.log(downloadUrl); + if (!!this.file.contentType || this.file.contentType === '') { + this.file.contentType = 'application/octet-stream'; + } + + let getParam = new HttpParams(); + getParam = getParam.set('downloadToken', this.authService.getAccessToken()); + + const remoteUrl = getUrl(this.file, OzgFileLinkRel.DOWNLOAD) + '?' + getParam.toString(); + const downloadUrl = `${ this.file.contentType }:${ this.file.name }:${ remoteUrl }` + event.dataTransfer.setData("DownloadURL", downloadUrl); } } -- GitLab