refactor(media): use asset-centric storage key layout
This commit is contained in:
@@ -5,7 +5,10 @@ import { buildMediaStorageKey } from "@/lib/media/storage-key"
|
||||
|
||||
type StoreLocalUploadParams = {
|
||||
file: File
|
||||
mediaType: string
|
||||
tenantId: string
|
||||
assetId: string
|
||||
fileRole: string
|
||||
variant: string
|
||||
}
|
||||
|
||||
type StoredUpload = {
|
||||
@@ -23,7 +26,13 @@ function resolveBaseDirectory(): string {
|
||||
}
|
||||
|
||||
export async function storeUploadLocally(params: StoreLocalUploadParams): Promise<StoredUpload> {
|
||||
const storageKey = buildMediaStorageKey(params.mediaType, params.file.name)
|
||||
const storageKey = buildMediaStorageKey({
|
||||
tenantId: params.tenantId,
|
||||
assetId: params.assetId,
|
||||
fileRole: params.fileRole,
|
||||
variant: params.variant,
|
||||
fileName: params.file.name,
|
||||
})
|
||||
const baseDirectory = resolveBaseDirectory()
|
||||
const outputPath = path.join(baseDirectory, storageKey)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user