Skip to content
Snippets Groups Projects
Commit 1e22fed5 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-1614 Bearer Token zur Download URL hinzufügen

parent 412e4ecc
Branches
Tags
No related merge requests found
import { Component, EventEmitter, Input, Output } from '@angular/core'; 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 { OzgFileLinkRel, OzgFileResource } from '@goofy-client/ozg-file-shared';
import { createEmptyStateResource, StateResource } from '@goofy-client/tech-shared'; import { createEmptyStateResource, StateResource } from '@goofy-client/tech-shared';
import { getUrl, hasLink } from '@ngxp/rest'; import { getUrl, hasLink } from '@ngxp/rest';
...@@ -20,6 +22,8 @@ export class OzgFileComponent { ...@@ -20,6 +22,8 @@ export class OzgFileComponent {
@Output() public startDownload: EventEmitter<OzgFileResource> = new EventEmitter<OzgFileResource>(); @Output() public startDownload: EventEmitter<OzgFileResource> = new EventEmitter<OzgFileResource>();
@Output() public startDelete: EventEmitter<OzgFileResource> = new EventEmitter<OzgFileResource>(); @Output() public startDelete: EventEmitter<OzgFileResource> = new EventEmitter<OzgFileResource>();
constructor(private authService: OAuthService) {}
get isDisabled(): boolean { get isDisabled(): boolean {
return this.getStateResource().loading; return this.getStateResource().loading;
} }
...@@ -37,13 +41,16 @@ export class OzgFileComponent { ...@@ -37,13 +41,16 @@ export class OzgFileComponent {
} }
dragStart(event) { dragStart(event) {
if (!!this.file.contentType || this.file.contentType === '') this.file.contentType = 'application/octet-stream'; if (!!this.file.contentType || this.file.contentType === '') {
const downloadUrl = `${ this.file.contentType }:${ this.file.name }:${ getUrl(this.file, OzgFileLinkRel.DOWNLOAD)}` this.file.contentType = 'application/octet-stream';
//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' let getParam = new HttpParams();
//const downloadUrl = 'image/jpeg:Helge1.jpg:http://localhost:4300/assets/Helge1.jpg' getParam = getParam.set('downloadToken', this.authService.getAccessToken());
console.log(downloadUrl);
const remoteUrl = getUrl(this.file, OzgFileLinkRel.DOWNLOAD) + '?' + getParam.toString();
const downloadUrl = `${ this.file.contentType }:${ this.file.name }:${ remoteUrl }`
event.dataTransfer.setData("DownloadURL", downloadUrl); event.dataTransfer.setData("DownloadURL", downloadUrl);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment