0

enter image description here enter image description here

I'm using AdminJS with NestJS as Plugin & TypeORM as Adapter, now I want to add one field for uploading file and save it on local storage but facing issue of component loader of 'adminjs' package, I'm new to AdminJS so please help me with my following code I had also attached images of issue.

const {
    AdminModule
} = await import('@adminjs/nestjs');
const {
    ComponentLoader
} = await import('adminjs');
const uploadModule = await import('@adminjs/upload');
const base = uploadModule.BaseProvider;
const componentLoader = new ComponentLoader()
class MyProvider extends base {
    constructor() {
        super('bucketName')
    }

    public async upload() {
        console.log('uploaded')
        return true
    }

    public async delete() {
        console.log('deleted')
        return true
    }

    public async path() {
        return '/fle-url'
    }
}

return AdminModule.createAdminAsync({
    useFactory: () => ({
        adminJsOptions: {
            resources: [{
                resource: Product,
                options: {
                    properties: {
                        photo: {
                            isVisible: {
                                list: true,
                                show: true,
                                edit: true,
                                filter: false,
                            },
                        },
                    },
                },
                features: [
                    uploadModule.default({
                        componentLoader,
                        provider: new MyProvider(),
                        properties: {
                            file: 'file',
                            key: 'filePath',
                            bucket: 'bucket',
                            filePath: 'path',
                        },
                        validation: {
                            mimeTypes: ['image/png']
                        },
                    }),
                ],
            }]
        }
    })
})
K_D
  • 1
  • 2

0 Answers0