|
|
@@ -301,12 +301,13 @@ export class VideoMediaService {
|
|
|
return Buffer.isBuffer(buffer) ? buffer : Buffer.from(buffer);
|
|
|
}
|
|
|
|
|
|
- async importExcelTags(file: Buffer) {
|
|
|
- if (!file?.buffer) {
|
|
|
+ async importExcelTags(file: Buffer | Uint8Array) {
|
|
|
+ const buffer = Buffer.isBuffer(file) ? file : Buffer.from(file ?? []);
|
|
|
+ if (!buffer.length) {
|
|
|
throw new BadRequestException('No file uploaded');
|
|
|
}
|
|
|
|
|
|
- const workbook = XLSX.read(file.buffer, { type: 'buffer' });
|
|
|
+ const workbook = XLSX.read(buffer, { type: 'buffer' });
|
|
|
const sheetName = workbook.SheetNames[0];
|
|
|
const sheet = sheetName ? workbook.Sheets[sheetName] : undefined;
|
|
|
|
|
|
@@ -352,6 +353,8 @@ export class VideoMediaService {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
+ candidateRows += 1;
|
|
|
+
|
|
|
const id = this.normalizeMongoIdToString(idRaw).trim();
|
|
|
if (!this.isObjectIdString(id)) {
|
|
|
skippedInvalidId += 1;
|
|
|
@@ -359,8 +362,6 @@ export class VideoMediaService {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- candidateRows += 1;
|
|
|
-
|
|
|
for (const tag of tags) {
|
|
|
uniqueTagNames.add(tag);
|
|
|
}
|