|
|
@ -243,18 +243,25 @@ export async function dataInsert(param: { |
|
|
|
|
|
|
|
|
|
|
|
if (fieldName in fields && fields[fieldName].uidt === UITypes.Attachment) { |
|
|
|
if (fieldName in fields && fields[fieldName].uidt === UITypes.Attachment) { |
|
|
|
attachments[fieldName] = attachments[fieldName] || []; |
|
|
|
attachments[fieldName] = attachments[fieldName] || []; |
|
|
|
const fileName = `${nanoid(6)}_${file.originalname}`; |
|
|
|
const fileName = `${nanoid(18)}${path.extname(file.originalname)}`; |
|
|
|
let url = await storageAdapter.fileCreate( |
|
|
|
|
|
|
|
|
|
|
|
const url = await storageAdapter.fileCreate( |
|
|
|
slash(path.join('nc', 'uploads', ...filePath, fileName)), |
|
|
|
slash(path.join('nc', 'uploads', ...filePath, fileName)), |
|
|
|
file |
|
|
|
file |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let attachmentPath; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if `url` is null, then it is local attachment
|
|
|
|
if (!url) { |
|
|
|
if (!url) { |
|
|
|
url = `${param.siteUrl}/download/${filePath.join('/')}/${fileName}`; |
|
|
|
// then store the attachment path only
|
|
|
|
|
|
|
|
// url will be constructed in `useAttachmentCell`
|
|
|
|
|
|
|
|
attachmentPath = `download/${filePath.join('/')}/${fileName}`; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
attachments[fieldName].push({ |
|
|
|
attachments[fieldName].push({ |
|
|
|
url, |
|
|
|
...(url ? { url } : {}), |
|
|
|
|
|
|
|
...(attachmentPath ? { path: attachmentPath } : {}), |
|
|
|
title: file.originalname, |
|
|
|
title: file.originalname, |
|
|
|
mimetype: file.mimetype, |
|
|
|
mimetype: file.mimetype, |
|
|
|
size: file.size, |
|
|
|
size: file.size, |
|
|
|