fix:unsigned urls when storing in db

This commit is contained in:
2025-10-14 16:05:39 +02:00
parent bf542e6b76
commit b4515d1d6a
2 changed files with 10 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
import sharp from 'sharp';
import { uploadToR2, getSignedR2Url } from './r2';
import { uploadToR2 } from './r2';
const THUMBNAIL_SIZE = 400;
const MAX_IMAGE_SIZE = 1920;
@@ -46,13 +46,8 @@ export async function processAndUploadImage(
uploadToR2(thumbFile, `${filename}-thumb.jpg`, 'image/jpeg')
]);
// Generate signed URLs (24 hour expiration for images)
const [url, thumbnailUrl] = await Promise.all([
getSignedR2Url(imagePath, 24 * 60 * 60), // 24 hours
getSignedR2Url(thumbPath, 24 * 60 * 60) // 24 hours
]);
return { url, thumbnailUrl };
// Return the R2 paths (not signed URLs) - signed URLs will be generated when needed
return { url: imagePath, thumbnailUrl: thumbPath };
}
export async function processAndUploadVideo(
@@ -66,12 +61,10 @@ export async function processAndUploadVideo(
// Upload video directly (no processing on server to save resources)
const videoPath = await uploadToR2(file, filename, 'video/mp4');
// Generate signed URL for video (24 hour expiration)
const url = await getSignedR2Url(videoPath, 24 * 60 * 60);
// For video thumbnail, generate on client-side or use placeholder
// This keeps server-side processing minimal
const thumbnailUrl = `/video-placeholder.jpg`; // Use static placeholder
return { url, thumbnailUrl };
// Return the R2 path (not signed URL) - signed URLs will be generated when needed
return { url: videoPath, thumbnailUrl };
}