fix: use public upload path for vip98k staging
This commit is contained in:
parent
608c0c8212
commit
8f3d2dca3c
@ -19,7 +19,6 @@ import { createLogger } from "@/lib/observability/logger";
|
|||||||
import { createDeferredUploadedImage } from "@/lib/storage/image-archive";
|
import { createDeferredUploadedImage } from "@/lib/storage/image-archive";
|
||||||
import {
|
import {
|
||||||
buildS3PublicUrl,
|
buildS3PublicUrl,
|
||||||
buildStorageObjectKey,
|
|
||||||
createS3Client,
|
createS3Client,
|
||||||
type S3UploadConfig,
|
type S3UploadConfig,
|
||||||
toDbS3UploadConfig,
|
toDbS3UploadConfig,
|
||||||
@ -65,7 +64,7 @@ const REFERENCE_DOWNLOAD_ATTEMPTS = 3;
|
|||||||
const REFERENCE_DOWNLOAD_TIMEOUT_MS = 120_000;
|
const REFERENCE_DOWNLOAD_TIMEOUT_MS = 120_000;
|
||||||
const MAX_REFERENCE_DOWNLOAD_BYTES = 40 * 1024 * 1024;
|
const MAX_REFERENCE_DOWNLOAD_BYTES = 40 * 1024 * 1024;
|
||||||
const REFERENCE_STAGING_CACHE_MS = 60_000;
|
const REFERENCE_STAGING_CACHE_MS = 60_000;
|
||||||
const REFERENCE_STAGING_PREFIX = "vip98k-references";
|
const REFERENCE_STAGING_KEY_PREFIX = "uploads/vip98k-";
|
||||||
|
|
||||||
type ReferenceStagingConfig = {
|
type ReferenceStagingConfig = {
|
||||||
sourcePublicUrl: string;
|
sourcePublicUrl: string;
|
||||||
@ -608,7 +607,9 @@ async function uploadReferenceImage(
|
|||||||
buffer: Buffer,
|
buffer: Buffer,
|
||||||
stagingConfig: ReferenceStagingConfig,
|
stagingConfig: ReferenceStagingConfig,
|
||||||
) {
|
) {
|
||||||
const key = buildStorageObjectKey("reference.jpg", REFERENCE_STAGING_PREFIX);
|
const key = `${REFERENCE_STAGING_KEY_PREFIX}${Date.now()}-${Math.random()
|
||||||
|
.toString(36)
|
||||||
|
.slice(2, 8)}.jpg`;
|
||||||
await createS3Client(stagingConfig.storageConfig).send(
|
await createS3Client(stagingConfig.storageConfig).send(
|
||||||
new PutObjectCommand({
|
new PutObjectCommand({
|
||||||
Bucket: stagingConfig.storageConfig.bucket,
|
Bucket: stagingConfig.storageConfig.bucket,
|
||||||
@ -676,7 +677,7 @@ async function ensurePublicMediaUrl(mediaUrl: string, mediaKind: "image" | "vide
|
|||||||
: null;
|
: null;
|
||||||
if (
|
if (
|
||||||
!stagingConfig ||
|
!stagingConfig ||
|
||||||
sourceObjectKey?.startsWith(`${REFERENCE_STAGING_PREFIX}/`) ||
|
sourceObjectKey?.startsWith(REFERENCE_STAGING_KEY_PREFIX) ||
|
||||||
!shouldStageVip98kReferenceUrl({
|
!shouldStageVip98kReferenceUrl({
|
||||||
mediaUrl: normalized,
|
mediaUrl: normalized,
|
||||||
sourcePublicUrl: stagingConfig.sourcePublicUrl,
|
sourcePublicUrl: stagingConfig.sourcePublicUrl,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user