use blob url for videoMeta (#8285)

Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com>
This commit is contained in:
Denis Tingaikin 2025-03-19 21:09:33 +03:00 committed by GitHub
parent 11b079a1f7
commit b885d355b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 31 additions and 12 deletions

View File

@ -156,6 +156,18 @@ export function getFileUploadParams (blobId: string, blob: Blob): FileUploadPara
return { method, url, headers }
}
/**
* @public
*/
export function getBlobUrl (file: string): string {
const fileUrl = getFileUrl(file)
const u = new URL(fileUrl)
if (u.searchParams.has('file')) {
return u.toString()
}
return fileUrl.split('/').slice(0, -1).join('/')
}
/**
* @public
*/

View File

@ -2,7 +2,7 @@ import type { Blob, Ref } from '@hcengineering/core'
import { concatLink } from '@hcengineering/core'
import { getMetadata } from '@hcengineering/platform'
import { getFileUrl, getCurrentWorkspaceUuid } from './file'
import { getFileUrl, getCurrentWorkspaceUuid, getBlobUrl } from './file'
import presentation from './plugin'
export interface PreviewConfig {
@ -158,7 +158,12 @@ export async function getVideoMeta (file: string, filename?: string): Promise<Vi
try {
const response = await fetch(url, { headers: { Authorization: `Bearer ${token}` } })
if (response.ok) {
return (await response.json()) as VideoMeta
const result = (await response.json()) as VideoMeta
if (result.hls !== undefined) {
result.hls.source = getBlobUrl(result.hls.source ?? '')
result.hls.thumbnail = getBlobUrl(result.hls.thumbnail ?? '')
}
return result
}
} catch {}
}

View File

@ -17,7 +17,7 @@ import { type FileUploadOptions, type FileUploadCallback } from '@hcengineering/
import Recorder from './components/Recorder.svelte'
import { showPopup } from '@hcengineering/ui'
import { type Blob, type Ref } from '@hcengineering/core'
import { getFileUrl } from '@hcengineering/presentation'
import { getBlobUrl } from '@hcengineering/presentation'
let recorderOppened = false
@ -65,12 +65,3 @@ function now (): string {
const date = new Date()
return date.toLocaleDateString() + ' ' + date.toLocaleTimeString()
}
function getBlobUrl (file: string): string {
const fileUrl = getFileUrl(file)
const u = new URL(fileUrl)
if (u.searchParams.has('file')) {
return u.toString()
}
return fileUrl.split('/').slice(0, -1).join('/')
}

View File

@ -0,0 +1,4 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",
"rigPackageName": "@hcengineering/platform-rig"
}

View File

@ -0,0 +1,7 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)'],
roots: ["./src"],
coverageReporters: ["text-summary", "html"]
}