Add thumbnail upload support to UploadModal and R2Service

- Added file input and browse button for thumbnails in `upload-modal.html`.
- Updated `UploadModal.js` to handle thumbnail file selection and UI toggling.
- Updated `r2Service.js` to upload thumbnail file (if present) to R2 and update metadata.
- Ensured thumbnail keys are derived from video keys for consistent naming.
This commit is contained in:
google-labs-jules[bot] committed 2026-01-09 03:03:35 +00:00
1 parent 77fba07fc3
commit 44aed00b5e
3 files changed
+76 -1

No files matched your search

+28
View File
@@ -636,6 +636,7 @@ class R2Service {
async handleCloudflareUploadSubmit({
npub = "",
file = null,
thumbnailFile = null,
metadata = {},
settingsInput = null,
publishVideoNote,
@@ -748,6 +749,33 @@ class R2Service {
try {
const s3 = makeR2Client({ accountId, accessKeyId, secretAccessKey });
if (thumbnailFile) {
this.setCloudflareUploadStatus("Uploading thumbnail...", "info");
const thumbExt = thumbnailFile.name.split('.').pop() || 'jpg';
const thumbKey = key.replace(/\.[^/.]+$/, "") + `.thumb.${thumbExt}`;
try {
await multipartUpload({
s3,
bucket: bucketEntry.bucket,
key: thumbKey,
file: thumbnailFile,
contentType: thumbnailFile.type || "image/jpeg",
});
const thumbUrl = buildPublicUrl(bucketEntry.publicBaseUrl, thumbKey);
if (typeof metadata === "object") {
metadata.thumbnail = thumbUrl;
}
} catch (err) {
userLogger.warn("Thumbnail upload failed, continuing with video...", err);
}
}
this.setCloudflareUploadStatus(
statusMessage,
bucketResult?.usedManagedFallback ? "warning" : "info"
);
await multipartUpload({
s3,
bucket: bucketEntry.bucket,