0

I'm uploading files to my Angular application using just HTML and JS. It works perfectly with all kind of files except for the Keynote ones.

I got the right name and size, but the type field is empty.

I've a simple file upload form like this:

<input type="file" class="d-none" (change)="addAttachments()" multiple #fileUpload />

When I check the file info, I got the correct 'type' for all kinds of file (images, documents, etc...) expect for the Keynote ones where it is empty.

My Angular code is like that

  addAttachments(): void {
    const files: FileList | null = this.fileUpload.nativeElement.files;
    if (files) {
      Array.prototype.forEach.call(files, (file) => {
           >>> file.type = ''
      }
    }
  }

Any idea of why keynote mime type is not recognized?

1 Answers1

0

Any idea of why keynote mime type is not recognized?

Because it isn't on your browser's map of file extensions to MIME types.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • Thanks, I supposed it was something like that... Do you know if I can I add it, or at least check the list of supported mime types? – Alberto Boz Dec 13 '22 at 09:50
  • Bug report to the browser vendor. Dig around in their source code if its an open source browser. I don't think there's an API. – Quentin Dec 13 '22 at 09:51
  • I forgot to mention that the browser is Chrome... that's the strange thing. – Alberto Boz Dec 13 '22 at 10:07