Search code examples
javascriptbase64

Base64 Data types


As part of an application I'm building there is a download option for files that are stored as Base64 strings. As such I need to pair the correct data types with the right files so they can be downloaded.

And I thought I had this pretty well fleshed out. However, it seems that docx files are downloading as doc files and xlsx files are downloading as xls files. Is there any way to download these in the correct file types? Most of the sites that have info related to this the company has blocked.

For docx I have data:application/msword

and for xlsx I have data:application/vnd.ms-excel


Solution

  • For .xlst: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

    For .docx: application/vnd.openxmlformats-officedocument.wordprocessingml.document

    See What is correct content-type for excel files?

    From http://filext.com/faq/office_mime_types.php:

    Ext    MIME Type
    .doc   application/msword
    .dot   application/msword
    .docx  application/vnd.openxmlformats-officedocument.wordprocessingml.document
    .dotx  application/vnd.openxmlformats-officedocument.wordprocessingml.template
    .docm  application/vnd.ms-word.document.macroEnabled.12
    .dotm  application/vnd.ms-word.template.macroEnabled.12
    .xls   application/vnd.ms-excel
    .xlt   application/vnd.ms-excel
    .xla   application/vnd.ms-excel
    .xlsx  application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
    .xltx  application/vnd.openxmlformats-officedocument.spreadsheetml.template
    .xlsm  application/vnd.ms-excel.sheet.macroEnabled.12
    .xltm  application/vnd.ms-excel.template.macroEnabled.12
    .xlam  application/vnd.ms-excel.addin.macroEnabled.12
    .xlsb  application/vnd.ms-excel.sheet.binary.macroEnabled.12