Unable to upload .py and .rb file (mdb-angular-file-upload v


Topic: Unable to upload .py and .rb file (mdb-angular-file-upload v8.0.0)

Kinanda Nugraha pro premium priority asked 6 days ago

mdb-angular-file-upload v8.0.0 Unable to upload .py and .rb file

TS:

ACCEPTED_EXTENSIONS = [
    '.c', '.cpp', '.css', '.csv', '.doc', '.docx', '.gif', '.go', '.html', '.java',
    '.jpeg', '.jpg', '.js', '.json', '.md', '.pdf', '.php', '.pkl', '.png', '.pptx',
    '.py', '.rb', '.tar', '.tex', '.ts', '.txt', '.webp', '.xlsx', '.xml', '.zip',
].join(',');

HTML:

<mdb-file-upload
    ...
    [acceptedExtensions]="ACCEPTED_EXTENSIONS"
    ...
></mdb-file-upload>

HOW TO REPRODUCE:

Upload .py or .rb file

ERROR:

{
    "type": "formatError",
    "message": "Your file has unsupported file format. (Supported format: .c .cpp .css .csv .doc .docx .gif .go .html .java .jpeg .jpg .js .json .md .pdf .php .pkl .png .pptx .py .rb .tar .tex .ts .txt .webp .xlsx .xml .zip)"
}

This error probably occurs because the mime types associated with those extensions are not available in our list of supported mime types. You can always extend this list by using [mimeTypes] input. Here is an example:

HTML:

<mdb-file-upload [acceptedExtensions]="ACCEPTED_EXTENSIONS" (uploadError)="onUploadError($event)" [mimeTypes]="mimeTypes"></mdb-file-upload>

TS:

  mimeTypes = [
    { mime_type: 'text/x-python', ext: '.py' },
    { mime_type: 'text/x-ruby', ext: '.rb' },
  ];

  ACCEPTED_EXTENSIONS = [
    '.c',
    '.cpp',
    '.css',
    '.csv',
    '.doc',
    '.docx',
    '.gif',
    '.go',
    '.html',
    '.java',
    '.jpeg',
    '.jpg',
    '.js',
    '.json',
    '.md',
    '.pdf',
    '.php',
    '.pkl',
    '.png',
    '.pptx',
    '.py',
    '.rb',
    '.tar',
    '.tex',
    '.ts',
    '.txt',
    '.webp',
    '.xlsx',
    '.xml',
    '.zip',
  ].join(',');

  onUploadError(event: any): void {
    console.error('Upload error:', event);
  }

Kinanda Nugraha pro premium priority commented 5 days ago

Thanks for investigating and prompt reply. Unfortunately adding [mimeTypes] didn't help. Please let me know if you have any other workaround.


Arkadiusz Idzikowski staff commented 3 days ago

That is really strange because I just added the mimeTypes input to the code you provided and that resolved problem with .py or .rb files upload. Before that I was getting the Your file has unsupported file format error.

Do you use v8.0.0 of the plugin? Could you please provide more information on how to reproduce the bug even with [mimeTypes] input included?

I edited my post and added full HTML and TS code I used.


Kinanda Nugraha pro premium priority commented 21 hours ago

Thanks, much appreciated. Yes I'm using plugin v8.0.0. But the project is using Angular 17, perhaps I need to upgrade to Angular 19 :(


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: MDB Angular
  • MDB Version: MDB5 8.0.0
  • Device: Macbook M1 Pro
  • Browser: Chrome 138.0.7204.169
  • OS: MacOS 15.5
  • Provided sample code: No
  • Provided link: No