refactor(media): use asset-centric storage key layout
This commit is contained in:
@@ -4,7 +4,10 @@ import { buildMediaStorageKey } from "@/lib/media/storage-key"
|
||||
|
||||
type StoreS3UploadParams = {
|
||||
file: File
|
||||
mediaType: string
|
||||
tenantId: string
|
||||
assetId: string
|
||||
fileRole: string
|
||||
variant: string
|
||||
}
|
||||
|
||||
type StoredUpload = {
|
||||
@@ -62,7 +65,13 @@ function createS3Client(config: S3Config): S3Client {
|
||||
export async function storeUploadToS3(params: StoreS3UploadParams): Promise<StoredUpload> {
|
||||
const config = resolveS3Config()
|
||||
const client = createS3Client(config)
|
||||
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 payload = new Uint8Array(await params.file.arrayBuffer())
|
||||
|
||||
await client.send(
|
||||
|
||||
Reference in New Issue
Block a user