fix issue where private files could no longer be downloaded

This commit is contained in:
Art Lowel
2021-01-27 17:32:15 +01:00
parent 0f5c3fdc92
commit 892512192b

View File

@@ -1,7 +1,7 @@
import { Inject, Injectable } from '@angular/core'; import { Inject, Injectable } from '@angular/core';
import { RawRestResponse } from '../dspace-rest/raw-rest-response.model'; import { RawRestResponse } from '../dspace-rest/raw-rest-response.model';
import { AuthService } from '../auth/auth.service'; import { AuthService } from '../auth/auth.service';
import { take, map } from 'rxjs/operators'; import { take, map, tap } from 'rxjs/operators';
import { NativeWindowRef, NativeWindowService } from '../services/window.service'; import { NativeWindowRef, NativeWindowService } from '../services/window.service';
import { URLCombiner } from '../url-combiner/url-combiner'; import { URLCombiner } from '../url-combiner/url-combiner';
import { hasValue } from '../../shared/empty.util'; import { hasValue } from '../../shared/empty.util';
@@ -23,10 +23,10 @@ export class FileService {
* @param url * @param url
* file url * file url
*/ */
downloadFile(url: string): Observable<string> { downloadFile(url: string) {
return this.authService.getShortlivedToken().pipe(take(1), map((token) => this.authService.getShortlivedToken().pipe(take(1)).subscribe((token) => {
hasValue(token) ? new URLCombiner(url, `?authentication-token=${token}`).toString() : url this._window.nativeWindow.location.href = hasValue(token) ? new URLCombiner(url, `?authentication-token=${token}`).toString() : url;
)); });
} }
/** /**