Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to solve this error "You have to define key property in options at uploadFileFeature"? #67

Open
yyash145 opened this issue Jun 16, 2023 · 1 comment

Comments

@yyash145
Copy link

{resource: IFile,
options:
{
navigation: HomePage,
properties: {
key: {
type: 'string',
},
// s3Key: {
// type: 'string',
// },
bucket: {
type: 'string',
},
mime: {
type: 'string',
},
comment: {
type: 'textarea',
isSortable: false,
},
},
},
features: [
uploadFeature({
componentLoader,
provider: { aws: S3_Credentials },
validation: { mimeTypes: ['image/png'] },
options:{
key: process.env.AWS_ACCESS_KEY_ID,
// s3Key: process.env.AWS_ACCESS_KEY_ID,
bucket: process.env.AWS_S3_BUCKET,
mime: 'image/png',
},
}),
],
},

I tried to insert an Image in MongoDB using Mongoose with the help of AWS S3, and by the documentation of @adminjs/upload, I got the code. When I got the above error, I replaced "s3Key" with "key" but nothing works..!!

I also tried it with Local File System, but got the same error there as well.
features: [
uploadFeature({
provider: localProvider,
validation: {
mimeTypes: ['image/png', 'application/pdf'],
},
options: {
key: 323,
bucket: './public/files',
s3Key: 'uploadFeature',
},
}),
],

I use https://docs.adminjs.co/basics/features/upload for reference.

@ai-leonid
Copy link

Try to pass properties option into uploadFeature function, like in these examples:
https://github.com/SoftwareBrothers/adminjs-upload/blob/master/example-app/src/admin/resources/photo/photo.resource.ts#L14

  features: [uploadFeature({
    componentLoader,
    provider: { local: { bucket: 'public', opts: {} } },
    properties: { file: 'file', key: 's3Key', bucket: 'bucket', mimeType: 'mime' },
    validation: { mimeTypes: ['image/png'] },
  })],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants