This commit is contained in:
2026-07-20 08:17:30 +08:00
parent 1290219077
commit 72a792d585
5 changed files with 35 additions and 19 deletions
+4 -9
View File
@@ -337,11 +337,11 @@ exports.getAsset = async (req, res) => {
// └─────────────────────────────────────────────────────────────────────────┘
//
// Shared by the single-file POST / and the multi-file POST /batch routes.
// `requireVideoThumbnail` is false for batch uploads — a bulk drop has no
// per-file thumbnail step, so videos land with thumbnail_url null and pick
// one up later via the existing "thumbnail-only" path in updateAsset().
// Thumbnails are optional for both video and audio — a video/audio asset can
// land with thumbnail_url null and pick one up later via the existing
// "thumbnail-only" path in updateAsset().
//
async function createAssetFromUpload({ file, thumbFile, body, user, requireVideoThumbnail = true, uploadId }) {
async function createAssetFromUpload({ file, thumbFile, body, user, uploadId }) {
const uploadedFiles = []; // [{ key, provider }]
try {
@@ -367,10 +367,6 @@ async function createAssetFromUpload({ file, thumbFile, body, user, requireVideo
const checksum = file.buffer ? resolveChecksum(file.buffer) : null;
const usesProvider = ["chibisafe", "s3"].includes(storage_provider);
if (file_type === "video" && requireVideoThumbnail && !thumbFile) {
throw Object.assign(new Error("A thumbnail image is required for video uploads."), { status: 400 });
}
if (usesProvider && !file.buffer) {
throw Object.assign(new Error("File buffer is required. Ensure multer uses memoryStorage."), { status: 400 });
}
@@ -575,7 +571,6 @@ exports.uploadAssetsBatch = async (req, res) => {
createdBy,
},
user: req.user,
requireVideoThumbnail: false,
});
results.push({ originalname: file.originalname, success: true, data: asset });
} catch (err) {