|
|
@ -1,7 +1,12 @@ |
|
|
|
import path from 'path'; |
|
|
|
import path from 'path'; |
|
|
|
import { Injectable } from '@nestjs/common'; |
|
|
|
import { Injectable } from '@nestjs/common'; |
|
|
|
import { nanoid } from 'nanoid'; |
|
|
|
import { nanoid } from 'nanoid'; |
|
|
|
import { ErrorMessages, UITypes, ViewTypes } from 'nocodb-sdk'; |
|
|
|
import { |
|
|
|
|
|
|
|
ErrorMessages, |
|
|
|
|
|
|
|
UITypes, |
|
|
|
|
|
|
|
ViewTypes, |
|
|
|
|
|
|
|
populateUniqueFileName, |
|
|
|
|
|
|
|
} from 'nocodb-sdk'; |
|
|
|
import slash from 'slash'; |
|
|
|
import slash from 'slash'; |
|
|
|
import { nocoExecute } from 'nc-help'; |
|
|
|
import { nocoExecute } from 'nc-help'; |
|
|
|
|
|
|
|
|
|
|
@ -396,16 +401,11 @@ export class PublicDatasService { |
|
|
|
attachments[fieldName] = attachments[fieldName] || []; |
|
|
|
attachments[fieldName] = attachments[fieldName] || []; |
|
|
|
let originalName = utf8ify(file.originalname); |
|
|
|
let originalName = utf8ify(file.originalname); |
|
|
|
|
|
|
|
|
|
|
|
let c = 1; |
|
|
|
originalName = populateUniqueFileName( |
|
|
|
while ( |
|
|
|
originalName, |
|
|
|
path.extname(originalName) && |
|
|
|
attachments[fieldName].map((att) => att?.title), |
|
|
|
attachments[fieldName].some((att) => att?.title === originalName) |
|
|
|
file.mimetype, |
|
|
|
) { |
|
|
|
|
|
|
|
originalName = originalName.replace( |
|
|
|
|
|
|
|
/(.+?)(\.[^.]+)$/, |
|
|
|
|
|
|
|
`$1(${c++})$2`, |
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const fileName = `${nanoid(18)}${path.extname(originalName)}`; |
|
|
|
const fileName = `${nanoid(18)}${path.extname(originalName)}`; |
|
|
|
|
|
|
|
|
|
|
|