|
|
|
@ -10,7 +10,6 @@ import hash from 'object-hash';
|
|
|
|
|
import moment from 'moment'; |
|
|
|
|
import type { AttachmentReqType, FileType } from 'nocodb-sdk'; |
|
|
|
|
import type { NcRequest } from '~/interface/config'; |
|
|
|
|
import type Sharp from 'sharp'; |
|
|
|
|
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; |
|
|
|
|
import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2'; |
|
|
|
|
import mimetypes, { mimeIcons } from '~/utils/mimeTypes'; |
|
|
|
@ -21,6 +20,7 @@ import { IJobsService } from '~/modules/jobs/jobs-service.interface';
|
|
|
|
|
import { JobTypes } from '~/interface/Jobs'; |
|
|
|
|
import { RootScopes } from '~/utils/globals'; |
|
|
|
|
import { validateAndNormaliseLocalPath } from '~/helpers/attachmentHelpers'; |
|
|
|
|
import Noco from '~/Noco'; |
|
|
|
|
|
|
|
|
|
interface AttachmentObject { |
|
|
|
|
url?: string; |
|
|
|
@ -88,15 +88,7 @@ export class AttachmentsService {
|
|
|
|
|
} = {}; |
|
|
|
|
|
|
|
|
|
if (file.mimetype.includes('image')) { |
|
|
|
|
let sharp: typeof 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}`, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
const sharp = Noco.sharp; |
|
|
|
|
|
|
|
|
|
if (sharp) { |
|
|
|
|
try { |
|
|
|
@ -261,12 +253,7 @@ export class AttachmentsService {
|
|
|
|
|
} = {}; |
|
|
|
|
|
|
|
|
|
if (mimeType.includes('image')) { |
|
|
|
|
let sharp: typeof Sharp; |
|
|
|
|
try { |
|
|
|
|
sharp = (await import('sharp')).default; |
|
|
|
|
} catch { |
|
|
|
|
// ignore
|
|
|
|
|
} |
|
|
|
|
const sharp = Noco.sharp; |
|
|
|
|
|
|
|
|
|
if (sharp) { |
|
|
|
|
try { |
|
|
|
@ -281,10 +268,6 @@ export class AttachmentsService {
|
|
|
|
|
} catch (e) { |
|
|
|
|
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.`, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|