Skip to content

Commit

Permalink
Merge pull request #4397 from bcgov/test
Browse files Browse the repository at this point in the history
psp-9316 correct stream route url, axios fileType. (#4388)
  • Loading branch information
devinleighsmith authored Oct 16, 2024
2 parents 87f50be + d525f8f commit 647a6a3
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
6 changes: 3 additions & 3 deletions source/backend/api/Pims.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<UserSecretsId>0ef6255f-9ea0-49ec-8c65-c172304b4926</UserSecretsId>
<Version>5.5.1-88.19</Version>
<Version>5.5.1-88.19</Version>
<AssemblyVersion>5.5.1.88</AssemblyVersion>
<Version>5.5.2-88.19</Version>
<Version>5.5.2-88.19</Version>
<AssemblyVersion>5.5.2.88</AssemblyVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<ProjectGuid>16BC0468-78F6-4C91-87DA-7403C919E646</ProjectGuid>
<TargetFramework>net8.0</TargetFramework>
Expand Down
2 changes: 1 addition & 1 deletion source/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "5.5.1-88.19",
"version": "5.5.2-88.19",
"private": true,
"dependencies": {
"@bcgov/bc-sans": "1.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ApiGen_System_HttpStatusCode } from '@/models/api/generated/ApiGen_Syst

import { DocumentViewerContext } from './context/DocumentViewerContext';
import { IDocumentPreviewViewProps } from './DocumentPreviewView';
import { createFileDownload } from './DownloadDocumentButton';
import { showFile } from './DownloadDocumentButton';
import { useDocumentProvider } from './hooks/useDocumentProvider';

export interface LoadedPage {
Expand All @@ -32,7 +32,7 @@ export const DocumentPreviewContainer: FC<
retrieveDocumentDetail,
downloadDocumentFilePageImage,
getDocumentFilePageList,
downloadWrappedDocumentFileLatest,
streamDocumentFileLatest,
retrieveDocumentDetailLoading,
getDocumentFilePageListLoading,
} = useDocumentProvider();
Expand Down Expand Up @@ -166,9 +166,7 @@ export const DocumentPreviewContainer: FC<
pages={documentPages}
resetDocumentPreview={resetDocumentPreview}
handleDownload={() => {
downloadWrappedDocumentFileLatest(previewDocumentId).then(file =>
createFileDownload(file),
);
streamDocumentFileLatest(previewDocumentId).then(response => showFile(response));
}}
/>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const createFileDownload = async (
}
};

const showFile = async (response: AxiosResponse<File, any>, fileName?: string) => {
export const showFile = async (response: AxiosResponse<File, any>, fileName?: string) => {
const groups = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/g.exec(
response.headers['content-disposition'],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,8 @@ export const DocumentDetailContainer: React.FunctionComponent<
const mayanMetadataResult = metadataResponse.payload?.results;

let mayanFileId: number | undefined = undefined;
if (exists(mayanMetadataResult) && mayanMetadataResult.length > 0) {
const document = mayanMetadataResult[0].document;
mayanFileId = document?.file_latest?.id;
if (exists(detailResponse)) {
mayanFileId = detailResponse?.payload?.file_latest?.id;
}

setDocument(document => ({
Expand Down
8 changes: 6 additions & 2 deletions source/frontend/src/hooks/pims-api/useApiDocuments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,14 @@ export const useApiDocuments = () => {
),

streamDocumentFileApiCall: (mayanDocumentId: number, mayanFileId: number) =>
api.get<File>(`/documents/storage/${mayanDocumentId}/stream/${mayanFileId}`),
api.get<File>(`/documents/storage/${mayanDocumentId}/files/${mayanFileId}/stream`, {
responseType: 'blob',
}),

streamDocumentFileLatestApiCall: (mayanDocumentId: number) =>
api.get<File>(`/documents/storage/${mayanDocumentId}/stream`),
api.get<File>(`/documents/storage/${mayanDocumentId}/stream`, {
responseType: 'blob',
}),

uploadDocumentRelationshipApiCall: (
relationshipType: ApiGen_CodeTypes_DocumentRelationType,
Expand Down

0 comments on commit 647a6a3

Please sign in to comment.