|
|
@ -1,5 +1,4 @@ |
|
|
|
import path from 'path'; |
|
|
|
import path from 'path'; |
|
|
|
import fs from 'fs'; |
|
|
|
|
|
|
|
import { |
|
|
|
import { |
|
|
|
Body, |
|
|
|
Body, |
|
|
|
Controller, |
|
|
|
Controller, |
|
|
@ -24,7 +23,7 @@ import { AttachmentsService } from '~/services/attachments.service'; |
|
|
|
import { PresignedUrl } from '~/models'; |
|
|
|
import { PresignedUrl } from '~/models'; |
|
|
|
import { MetaApiLimiterGuard } from '~/guards/meta-api-limiter.guard'; |
|
|
|
import { MetaApiLimiterGuard } from '~/guards/meta-api-limiter.guard'; |
|
|
|
import { NcContext, NcRequest } from '~/interface/config'; |
|
|
|
import { NcContext, NcRequest } from '~/interface/config'; |
|
|
|
import { isPreviewAllowed, fileExists } from '~/helpers/attachmentHelpers'; |
|
|
|
import { isPreviewAllowed, localFileExists } from '~/helpers/attachmentHelpers'; |
|
|
|
import { DataTableService } from '~/services/data-table.service'; |
|
|
|
import { DataTableService } from '~/services/data-table.service'; |
|
|
|
import { TenantContext } from '~/decorators/tenant-context.decorator'; |
|
|
|
import { TenantContext } from '~/decorators/tenant-context.decorator'; |
|
|
|
import { DataApiLimiterGuard } from '~/guards/data-api-limiter.guard'; |
|
|
|
import { DataApiLimiterGuard } from '~/guards/data-api-limiter.guard'; |
|
|
@ -85,7 +84,7 @@ export class AttachmentsController { |
|
|
|
path: path.join('nc', 'uploads', filename), |
|
|
|
path: path.join('nc', 'uploads', filename), |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (!await fs.promises.stat(file.path)) { |
|
|
|
if (!(await localFileExists(file.path))) { |
|
|
|
return res.status(404).send('File not found'); |
|
|
|
return res.status(404).send('File not found'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -126,7 +125,7 @@ export class AttachmentsController { |
|
|
|
), |
|
|
|
), |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (!(await fileExists(file.path))) { |
|
|
|
if (!(await localFileExists(file.path))) { |
|
|
|
return res.status(404).send('File not found'); |
|
|
|
return res.status(404).send('File not found'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -172,7 +171,7 @@ export class AttachmentsController { |
|
|
|
path: path.join('nc', filePath, fpath), |
|
|
|
path: path.join('nc', filePath, fpath), |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (!(await fileExists(file.path))) { |
|
|
|
if (!(await localFileExists(file.path))) { |
|
|
|
return res.status(404).send('File not found'); |
|
|
|
return res.status(404).send('File not found'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|