session download test

This commit is contained in:
Timo Bejan 2022-01-24 19:35:14 +02:00
parent cfafc88121
commit 319b4960b1
2 changed files with 9 additions and 7 deletions

View File

@ -7,9 +7,9 @@ import {
IPrepareDownloadRequest,
IRemoveDownloadRequest,
} from '@red/domain';
import { interval, Observable } from 'rxjs';
import { Observable } from 'rxjs';
import { ConfigService } from '@services/config.service';
import { filter, map, switchMap, tap, withLatestFrom } from 'rxjs/operators';
import { map, switchMap, tap } from 'rxjs/operators';
import { KeycloakService } from 'keycloak-angular';
import { UserService } from '@services/user.service';
import { EntitiesService, List, mapEach, RequiredParam, Validate } from '@iqser/common-ui';
@ -44,11 +44,12 @@ export class FileDownloadService extends EntitiesService<DownloadStatus, IDownlo
}
async performDownload(status: DownloadStatus) {
const token = await this._keycloakService.getToken();
const anchor = document.createElement('a');
anchor.href = `${this._configService.values.API_URL}/async/download?access_token=${encodeURIComponent(
token,
)}&storageId=${encodeURIComponent(status.storageId)}`;
anchor.href = `${this._configService.values.API_URL}/async/download?storageId=${encodeURIComponent(status.storageId)}`;
if (this._configService.values.USE_SESSION_FOR_DOWNLOAD) {
const token = await this._keycloakService.getToken();
anchor.href = anchor.href + `&access_token=${encodeURIComponent(token)}`;
}
anchor.download = status.filename;
anchor.target = '_blank';

View File

@ -19,5 +19,6 @@
"OAUTH_IDP_HINT": null,
"OAUTH_URL": "https://aks-staging.iqser.cloud/auth/realms/redaction",
"RECENT_PERIOD_IN_HOURS": 24,
"SELECTION_MODE": "structural"
"SELECTION_MODE": "structural",
"USE_SESSION_FOR_DOWNLOAD": false
}