diff --git a/packages/presentation/src/file.ts b/packages/presentation/src/file.ts index 4b0e6860e8..a3405427f6 100644 --- a/packages/presentation/src/file.ts +++ b/packages/presentation/src/file.ts @@ -99,12 +99,9 @@ function getFilesUrl (): string { return filesUrl.includes('://') ? filesUrl : concatLink(frontUrl, filesUrl) } -export function getCurrentWorkspaceId (): WorkspaceDataId { - return ( - getMetadata(plugin.metadata.WorkspaceDataId) ?? - (getMetadata(plugin.metadata.WorkspaceUuid) as unknown as WorkspaceDataId) ?? - ('' as WorkspaceDataId) - ) +export function getCurrentWorkspaceUuid (): WorkspaceDataId { + const workspaceUuid = getMetadata(plugin.metadata.WorkspaceUuid) ?? '' + return workspaceUuid as WorkspaceDataId } /** @@ -120,7 +117,7 @@ export function generateFileId (): string { export function getUploadUrl (): string { const template = getMetadata(plugin.metadata.UploadURL) ?? defaultUploadUrl - return template.replaceAll(':workspace', encodeURIComponent(getCurrentWorkspaceId())) + return template.replaceAll(':workspace', encodeURIComponent(getCurrentWorkspaceUuid())) } function getUploadConfig (): UploadConfig { @@ -142,7 +139,7 @@ function getFileUploadMethod (blob: Blob): { method: FileUploadMethod, url: stri * @public */ export function getFileUploadParams (blobId: string, blob: Blob): FileUploadParams { - const workspaceId = encodeURIComponent(getCurrentWorkspaceId()) + const workspaceId = encodeURIComponent(getCurrentWorkspaceUuid()) const fileId = encodeURIComponent(blobId) const { method, url: urlTemplate } = getFileUploadMethod(blob) @@ -170,7 +167,7 @@ export function getFileUrl (file: string, filename?: string): string { const template = getFilesUrl() return template .replaceAll(':filename', encodeURIComponent(filename ?? file)) - .replaceAll(':workspace', encodeURIComponent(getCurrentWorkspaceId())) + .replaceAll(':workspace', encodeURIComponent(getCurrentWorkspaceUuid())) .replaceAll(':blobId', encodeURIComponent(file)) } diff --git a/packages/presentation/src/preview.ts b/packages/presentation/src/preview.ts index 256a9cd1c1..b91827c2bc 100644 --- a/packages/presentation/src/preview.ts +++ b/packages/presentation/src/preview.ts @@ -2,7 +2,7 @@ import type { Blob, Ref } from '@hcengineering/core' import { concatLink } from '@hcengineering/core' import { getMetadata } from '@hcengineering/platform' -import { getFileUrl, getCurrentWorkspaceId } from './file' +import { getFileUrl, getCurrentWorkspaceUuid } from './file' import presentation from './plugin' export interface PreviewConfig { @@ -16,7 +16,7 @@ export interface VideoMeta { hls: string } -const defaultImagePreview = (): string => `/files/${getCurrentWorkspaceId()}?file=:blobId&size=:size` +const defaultImagePreview = (): string => `/files/${getCurrentWorkspaceUuid()}?file=:blobId&size=:size` /** * @@ -93,7 +93,7 @@ function blobToSrcSet ( return '' } - let url = cfg.image.replaceAll(':workspace', encodeURIComponent(getCurrentWorkspaceId())) + let url = cfg.image.replaceAll(':workspace', encodeURIComponent(getCurrentWorkspaceUuid())) const downloadUrl = getFileUrl(blob) const frontUrl = getMetadata(presentation.metadata.FrontUrl) ?? window.location.origin @@ -139,7 +139,7 @@ export async function getVideoMeta (file: string, filename?: string): Promise