Scenario:
- I use the forge component to create an .xlsx file
- Without changes I try to upload that same file
- The upload files with error message: Invalid File Type
This error originates from another Forge extension: FileTypeExtension where we use the FileType action to validate the file type.
After editing the file it uploads fine without errors.What may be the cause of this is that the Excel file downloaded is protected by default.
My question:Is there a way to work around the Protected state with the download action?
Hi Toine,
The issue you are having is most definitelly unrelated with the protected view. This because the protected view is not determined by anything in the file content but by your Office installation, as indicated by this post:
https://stackoverflow.com/questions/22294690/apache-poi-enable-excel-editing
I've looked inside the FileTypeExtension, and found out that the extension looks at the first 8 bytes of the file in order to determine its type. For office files it is expecting the bytes sequence "50-4B-03-04-14-00-06-00", which is true for files generated using MS Office, but not true for files generated by NPOI (the library OfficeUtils uses), and also not true for files generated by LibreOffice. This explains the fact that the extension works after you save the file in MS Office, as the file is completelly re-generated.
If the issue would only manifest itself with NPOI generated files, I would say that this would be an NPOI issue. But since it happens for LibreOffice generated files as well, I must say that it is maybe better for you to try to find a more robust alternative to the FileTypeExtension.
Hope this information helps!