How to change maxFileSize on AdminJS Upload feature?

51 Views Asked by At

In AdminJS document, it says I can change max file size in upload feature validation. I tried, but it does change on frontend side showing (max file size: 1gb) but it still shows error on the server with max file exceeded 200mb. (this error is from formidable, not from the server) I know that AdminJS upload feature is using express formidable, and I want to know how to change the maximum file size on the server. This is my code with AdminJS.

uploadFeature({
        componentLoader,
        provider: { aws: AWScredentials },
        validation: { 
          mimeTypes: ['image/png', 'image/jpeg', 'application/pdf', 'application/zip', 'application/vnd.rar', 'application/x-rar-compressed', 'application/octet-stream', 'application/x-zip-compressed', 'multipart/x-zip', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'],
          maxSize: 500 * 1024 * 1024 // 1000000000
        },
        
      uploadPath: (record, filename) => {
        return `download/${filename}`
      }
      }),
    ],

Is there any solution to change directly on server (i'm using nginx), or do I need to edit on code? and how?

1

There are 1 best solutions below

0
Hariram M On

validate={{maxSize: 1024000, mimeTypes:["image/png", "image/jpg", "image/jpeg"]}} multiple={false} uploadLimitIn='MB' translations={{placeholder: "Upload merchant's store image here!", unsupportedSize: "{{fileName}} size is exceeding 1MB", unsupportedType: "{{fileName}} has unsupported type: {{fileType}}"}}

Here i have used the above validation property to restrict the file upload for 1MB. you can use unsupportedSize for the required size as needed.

for more refer here : DropZone in adminjs