|
|
@ -10,7 +10,6 @@ import hash from 'object-hash'; |
|
|
|
import moment from 'moment'; |
|
|
|
import moment from 'moment'; |
|
|
|
import type { AttachmentReqType, FileType } from 'nocodb-sdk'; |
|
|
|
import type { AttachmentReqType, FileType } from 'nocodb-sdk'; |
|
|
|
import type { NcRequest } from '~/interface/config'; |
|
|
|
import type { NcRequest } from '~/interface/config'; |
|
|
|
import type Sharp from 'sharp'; |
|
|
|
|
|
|
|
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; |
|
|
|
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; |
|
|
|
import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2'; |
|
|
|
import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2'; |
|
|
|
import mimetypes, { mimeIcons } from '~/utils/mimeTypes'; |
|
|
|
import mimetypes, { mimeIcons } from '~/utils/mimeTypes'; |
|
|
@ -21,6 +20,7 @@ import { IJobsService } from '~/modules/jobs/jobs-service.interface'; |
|
|
|
import { JobTypes } from '~/interface/Jobs'; |
|
|
|
import { JobTypes } from '~/interface/Jobs'; |
|
|
|
import { RootScopes } from '~/utils/globals'; |
|
|
|
import { RootScopes } from '~/utils/globals'; |
|
|
|
import { validateAndNormaliseLocalPath } from '~/helpers/attachmentHelpers'; |
|
|
|
import { validateAndNormaliseLocalPath } from '~/helpers/attachmentHelpers'; |
|
|
|
|
|
|
|
import Noco from '~/Noco'; |
|
|
|
|
|
|
|
|
|
|
|
interface AttachmentObject { |
|
|
|
interface AttachmentObject { |
|
|
|
url?: string; |
|
|
|
url?: string; |
|
|
@ -88,15 +88,7 @@ export class AttachmentsService { |
|
|
|
} = {}; |
|
|
|
} = {}; |
|
|
|
|
|
|
|
|
|
|
|
if (file.mimetype.includes('image')) { |
|
|
|
if (file.mimetype.includes('image')) { |
|
|
|
let sharp: typeof Sharp; |
|
|
|
const sharp = Noco.sharp; |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
sharp = (await import('sharp')).default; |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
this.logger.warn( |
|
|
|
|
|
|
|
`Thumbnail generation is not supported in this platform at the moment. Error: ${e.message}`, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sharp) { |
|
|
|
if (sharp) { |
|
|
|
try { |
|
|
|
try { |
|
|
@ -261,12 +253,7 @@ export class AttachmentsService { |
|
|
|
} = {}; |
|
|
|
} = {}; |
|
|
|
|
|
|
|
|
|
|
|
if (mimeType.includes('image')) { |
|
|
|
if (mimeType.includes('image')) { |
|
|
|
let sharp: typeof Sharp; |
|
|
|
const sharp = Noco.sharp; |
|
|
|
try { |
|
|
|
|
|
|
|
sharp = (await import('sharp')).default; |
|
|
|
|
|
|
|
} catch { |
|
|
|
|
|
|
|
// ignore
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sharp) { |
|
|
|
if (sharp) { |
|
|
|
try { |
|
|
|
try { |
|
|
@ -281,10 +268,6 @@ export class AttachmentsService { |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
this.logger.error(`${file.path} is not an image file`); |
|
|
|
this.logger.error(`${file.path} is not an image file`); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
this.logger.warn( |
|
|
|
|
|
|
|
`Thumbnail generation is not supported in this platform at the moment.`, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|