diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts index 5761abc8ce..fac240a4a8 100644 --- a/packages/nocodb/src/db/BaseModelSqlv2.ts +++ b/packages/nocodb/src/db/BaseModelSqlv2.ts @@ -8184,7 +8184,7 @@ class BaseModelSqlv2 { }; const thumbnailPath = `thumbnails/${lookedUpAttachment.path.replace( - /^download\//, + /^download[/\\]/i, '', )}`; @@ -8257,7 +8257,7 @@ class BaseModelSqlv2 { } const thumbnailPath = `thumbnails/${attachment.path.replace( - /^download\//, + /^download[/\\]/i, '', )}`; diff --git a/packages/nocodb/src/models/PresignedUrl.ts b/packages/nocodb/src/models/PresignedUrl.ts index 65db77d78d..3403ad400d 100644 --- a/packages/nocodb/src/models/PresignedUrl.ts +++ b/packages/nocodb/src/models/PresignedUrl.ts @@ -246,7 +246,7 @@ export default class PresignedUrl { if (attachment?.path) { nestedObj.signedPath = await PresignedUrl.getSignedUrl( { - pathOrUrl: attachment.path.replace(/^download\//, ''), + pathOrUrl: attachment.path.replace(/^download[/\\]/i, ''), preview, mimetype: mimetype || attachment.mimetype, ...(extra ? { ...extra } : {}), diff --git a/packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts b/packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts index 654008702a..25b8f54903 100644 --- a/packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts +++ b/packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts @@ -75,7 +75,7 @@ export class ThumbnailGeneratorProcessor { tiny: path.join('nc', 'thumbnails', relativePath, 'tiny.jpg'), }; - const sharpImage = await sharp(file, { + const sharpImage = sharp(file, { limitInputPixels: false, }); @@ -135,7 +135,7 @@ export class ThumbnailGeneratorProcessor { relativePath = path.join( 'nc', 'uploads', - attachment.path.replace(/^download\//, ''), + attachment.path.replace(/^download[/\\]/i, ''), ); } else if (attachment.url) { relativePath = getPathFromUrl(attachment.url).replace(/^\/+/, ''); @@ -144,7 +144,7 @@ export class ThumbnailGeneratorProcessor { const file = await storageAdapter.fileRead(relativePath); // remove everything before 'nc/uploads/' (including nc/uploads/) in relativePath - relativePath = relativePath.replace(/.*?nc\/uploads\//, ''); + relativePath = relativePath.replace(/^.*?nc[/\\]uploads[/\\]/, ''); return { file, relativePath }; } diff --git a/packages/nocodb/src/plugins/mino/Minio.ts b/packages/nocodb/src/plugins/mino/Minio.ts index ba93a2c620..0efa2c47ab 100644 --- a/packages/nocodb/src/plugins/mino/Minio.ts +++ b/packages/nocodb/src/plugins/mino/Minio.ts @@ -198,8 +198,10 @@ export default class Minio implements IStorageAdapterV2 { return Promise.resolve(undefined); } - public async fileDelete(_path: string): Promise { - throw new Error('Method not implemented.'); + public async fileDelete(path: string): Promise { + return this.minioClient.removeObject(this.input.bucket, path).then(() => { + return true; + }); } public async scanFiles(_globPattern: string): Promise { diff --git a/packages/nocodb/src/plugins/storage/Local.ts b/packages/nocodb/src/plugins/storage/Local.ts index d907178792..ecb27011a5 100644 --- a/packages/nocodb/src/plugins/storage/Local.ts +++ b/packages/nocodb/src/plugins/storage/Local.ts @@ -112,15 +112,18 @@ export default class Local implements IStorageAdapterV2 { } public async scanFiles(globPattern: string) { + // Normalize the path separator + globPattern = globPattern.replace(/\//g, path.sep); + // remove all dots from the glob pattern globPattern = globPattern.replace(/\./g, ''); // remove the leading slash globPattern = globPattern.replace(/^\//, ''); - // make sure pattern starts with nc/uploads/ - if (!globPattern.startsWith('nc/uploads/')) { - globPattern = `nc/uploads/${globPattern}`; + // Ensure the pattern starts with 'nc/uploads/' + if (!globPattern.startsWith(path.join('nc', 'uploads'))) { + globPattern = path.join('nc', 'uploads', globPattern); } const stream = globStream(globPattern, {