diff --git a/src/app/features/files/pages/file-detail/file-detail.component.ts b/src/app/features/files/pages/file-detail/file-detail.component.ts index 9e4060419..40ff066d9 100644 --- a/src/app/features/files/pages/file-detail/file-detail.component.ts +++ b/src/app/features/files/pages/file-detail/file-detail.component.ts @@ -183,8 +183,8 @@ export class FileDetailComponent { this.actions.getFileResourceMetadata(this.resourceId, this.resourceType); this.actions.getFileResourceContributors(this.resourceId, this.resourceType); if (fileId) { - const fileProvider = this.file()?.provider || ''; - this.actions.getFileRevisions(this.resourceId, fileProvider, fileId); + const storageLink = this.file()?.links.download || ''; + this.actions.getFileRevisions(storageLink, fileId); this.actions.getCedarTemplates(); this.actions.getCedarRecords(fileId, ResourceType.File); } diff --git a/src/app/features/files/pages/files/files.component.ts b/src/app/features/files/pages/files/files.component.ts index b437410aa..e7b09b84b 100644 --- a/src/app/features/files/pages/files/files.component.ts +++ b/src/app/features/files/pages/files/files.component.ts @@ -211,7 +211,7 @@ export class FilesComponent { effect(() => { const rootFolders = this.rootFolders(); if (rootFolders) { - const osfRootFolder = rootFolders.find((folder: OsfFile) => folder.provider === 'osfstorage'); + const osfRootFolder = rootFolders.find((folder: OsfFile) => folder.provider === FileProvider.OsfStorage); if (osfRootFolder) { this.currentRootFolder.set({ label: this.translateService.instant('files.storageLocation'), @@ -334,14 +334,14 @@ export class FilesComponent { const resourceId = this.resourceId(); const folderId = this.currentFolder()?.id ?? ''; const isRootFolder = !this.currentFolder()?.relationships?.parentFolderLink; - const provider = this.currentRootFolder()?.folder?.provider ?? 'osfstorage'; + const storageLink = this.currentRootFolder()?.folder?.links?.download ?? ''; if (resourceId && folderId) { if (isRootFolder) { - const link = this.filesService.getFolderDownloadLink(resourceId, provider, '', true); + const link = this.filesService.getFolderDownloadLink(storageLink, '', true); window.open(link, '_blank')?.focus(); } else { - const link = this.filesService.getFolderDownloadLink(resourceId, provider, folderId, false); + const link = this.filesService.getFolderDownloadLink(storageLink, folderId, false); window.open(link, '_blank')?.focus(); } } @@ -384,7 +384,7 @@ export class FilesComponent { } getAddonName(addons: ConfiguredAddonModel[], provider: string): string { - if (provider === 'osfstorage') { + if (provider === FileProvider.OsfStorage) { return this.translateService.instant('files.storageLocation'); } else { return addons.find((addon) => addon.externalServiceName === provider)?.displayName ?? ''; diff --git a/src/app/features/files/store/files.actions.ts b/src/app/features/files/store/files.actions.ts index 1f8f55de7..96ef709fa 100644 --- a/src/app/features/files/store/files.actions.ts +++ b/src/app/features/files/store/files.actions.ts @@ -115,8 +115,7 @@ export class GetFileRevisions { static readonly type = '[Files] Get Revisions'; constructor( - public resourceId: string, - public fileProvider: string, + public link: string, public fileId: string ) {} } diff --git a/src/app/features/files/store/files.state.ts b/src/app/features/files/store/files.state.ts index dd97d10de..d0e977eb2 100644 --- a/src/app/features/files/store/files.state.ts +++ b/src/app/features/files/store/files.state.ts @@ -257,7 +257,7 @@ export class FilesState { const state = ctx.getState(); ctx.patchState({ fileRevisions: { ...state.fileRevisions, isLoading: true, error: null } }); - return this.filesService.getFileRevisions(action.resourceId, action.fileProvider, action.fileId).pipe( + return this.filesService.getFileRevisions(action.link, action.fileId).pipe( tap({ next: (revisions) => { ctx.patchState({ fileRevisions: { data: revisions, isLoading: false, error: null } }); diff --git a/src/app/shared/components/files-tree/files-tree.component.ts b/src/app/shared/components/files-tree/files-tree.component.ts index 5fbf8c777..579285b32 100644 --- a/src/app/shared/components/files-tree/files-tree.component.ts +++ b/src/app/shared/components/files-tree/files-tree.component.ts @@ -333,12 +333,13 @@ export class FilesTreeComponent implements OnDestroy, AfterViewInit { downloadFolder(folderId: string, rootFolder: boolean): void { const resourceId = this.resourceId(); + const storageLink = this.currentFolder()?.links?.download ?? ''; if (resourceId && folderId) { if (rootFolder) { - const link = this.filesService.getFolderDownloadLink(resourceId, this.provider()!, '', true); + const link = this.filesService.getFolderDownloadLink(storageLink, '', true); window.open(link, '_blank')?.focus(); } else { - const link = this.filesService.getFolderDownloadLink(resourceId, this.provider()!, folderId, false); + const link = this.filesService.getFolderDownloadLink(storageLink, folderId, false); window.open(link, '_blank')?.focus(); } } diff --git a/src/app/shared/mappers/files/files.mapper.ts b/src/app/shared/mappers/files/files.mapper.ts index 39fceca67..ed8578bea 100644 --- a/src/app/shared/mappers/files/files.mapper.ts +++ b/src/app/shared/mappers/files/files.mapper.ts @@ -33,7 +33,7 @@ export function MapFile( move: file.links?.move, upload: file.links?.upload, delete: file.links?.delete, - download: file.links?.download, + download: file.attributes.kind === 'folder' ? file.links.upload : file.links?.download, self: file.links?.self, html: file.links?.html, render: file.links?.render, diff --git a/src/app/shared/services/files.service.ts b/src/app/shared/services/files.service.ts index 441e6cb55..8b54eee73 100644 --- a/src/app/shared/services/files.service.ts +++ b/src/app/shared/services/files.service.ts @@ -165,11 +165,11 @@ export class FilesService { ); } - getFolderDownloadLink(resourceId: string, provider: string, folderId: string, isRootFolder: boolean): string { + getFolderDownloadLink(storageLink: string, folderId: string, isRootFolder: boolean): string { if (isRootFolder) { - return `${environment.fileApiUrl}/resources/${resourceId}/providers/${provider}/?zip=`; + return `${storageLink}?zip=`; } - return `${environment.fileApiUrl}/resources/${resourceId}/providers/${provider}/${folderId}/?zip=`; + return `${storageLink}${folderId}/?zip=`; } getFileTarget(fileGuid: string): Observable { @@ -248,11 +248,9 @@ export class FilesService { .pipe(map((response) => MapFileCustomMetadata(response))); } - getFileRevisions(resourceId: string, provider: string, fileId: string): Observable { + getFileRevisions(link: string, fileId: string): Observable { return this.jsonApiService - .get( - `${environment.fileApiUrl}/resources/${resourceId}/providers/${provider}/${fileId}?revisions=` - ) + .get(`${link}/${fileId}?revisions=`) .pipe(map((response) => MapFileRevision(response.data))); } diff --git a/src/environments/environment.development.ts b/src/environments/environment.development.ts index fef1c37a5..5138269ee 100644 --- a/src/environments/environment.development.ts +++ b/src/environments/environment.development.ts @@ -26,10 +26,6 @@ export const environment = { * URL for the OSF Addons API (v1). */ addonsApiUrl: 'https://addons.staging4.osf.io/v1', - /** - * URL for file-related operations on the US storage region. - */ - fileApiUrl: 'https://files.us.staging4.osf.io/v1', /** * API endpoint for funder metadata resolution via Crossref. */ diff --git a/src/environments/environment.test-osf.ts b/src/environments/environment.test-osf.ts index f4867f106..c2bef93fb 100644 --- a/src/environments/environment.test-osf.ts +++ b/src/environments/environment.test-osf.ts @@ -7,7 +7,6 @@ export const environment = { apiDomainUrl: 'https://api.test.osf.io', shareTroveUrl: 'https://test-share.osf.io/trove', addonsApiUrl: 'https://addons.test.osf.io/v1', - fileApiUrl: 'https://files.us.test.osf.io/v1', funderApiUrl: 'https://api.crossref.org/', casUrl: 'https://accounts.test.osf.io', recaptchaSiteKey: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI', diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 901305e6f..1f58cbc79 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -26,10 +26,6 @@ export const environment = { * URL for the OSF Addons API (v1). */ addonsApiUrl: 'https://addons.staging4.osf.io/v1', - /** - * URL for file-related operations on the US storage region. - */ - fileApiUrl: 'https://files.us.staging4.osf.io/v1', /** * API endpoint for funder metadata resolution via Crossref. */