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
No related branches found
No related tags found
No related merge requests found
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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment