vincentmorneau / apex-publish-static-files

Publish a local directory to Oracle APEX

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mimeType check of .js files return null

marvinamorim opened this issue · comments

Hello.

When executing the check of mime type of a .js file, it's returned null.
This happen at this line:

var mimeType = java.nio.file.Files.probeContentType(java.nio.file.Files.createTempFile("dummy", extension));

So, with the new condition to validate mimeType, none of my js files are being uploaded anymore.

The line of the if that verify the mimeType:

Is this a bug? Or it should work like this?

Thanks in advance.

Hmm probably a bug. My files are all getting uploaded.

What is your java version?

~ $ java -version
java version "9.0.1"
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

Hi, i'm using Windows 10 (latest build), and using the latest java version available on official site https://www.java.com/en/download/

λ java -version
java version "1.8.0_271"
Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.271-b09, mixed mode)

Is there anything I can do to help to debug this problem?

Hello.
Is there any update about this issue?

commented

Hi

I had the exact same problem but with the installation of version 4.1.6 of Apex Nitro. Only my .css files were getting uploaded, .js and font files were not uploaded. After some searching I learned that Windows doesn't work as nice with MimeTypes as Linux and MacOs. Windows relies more on the extension of a file than on the mimetype to know what the file is all about. In most cases, Windows (it seems) doesn't even know what the mimetype is of some files.

On my system I use the command reg query HKCR\.extension to find out the mimetype and other relevant information about a particular extension.

`C:\WINDOWS\System32>reg query HKCR.css

HKEY_CLASSES_ROOT.css
(Default) REG_SZ CSSfile
Content Type REG_SZ text/css
PerceivedType REG_SZ text
`

For css files, the content type is clearly shown as text/css. This information is also used in the check for uploading the files. For js files however:

`C:\WINDOWS\System32>reg query HKCR.js

HKEY_CLASSES_ROOT.js
(Default) REG_SZ JSFile

HKEY_CLASSES_ROOT.js\PersistentHandler`

the content type is missing which leads to null in the check. Hence the file is not uploaded.

I have 2 possible solutions to get it working again. You can add the Content Type string manually in the registry for the file extensions that don't upload. Just go to key Computer\HKEY_CLASSES_ROOT.js and add a new String value of key Content Type and value text/javascript.

regedit_snip

Although this works, it's not the best solution and you don't want to add it manually for every extension that has no mimetype in your Windows environment. The second solution is easier, just downgrade the version of the module apex-publish-static-files in your package.json file to 2.0.2 and run npm update again in the directory where you modified the package.json. Version 2.0.3 will be deleted and replaced with version 2.0.2 where the check about mimetypes is not present.

package json_snip

Both solutions are however not a final solution, so I'm hoping Vincent and the rest of the team will come up with a proper solution. Maybe default the mimetype to text/plain if the check gives null back or use a fallback list of known mimetypes (https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types).

Hope this helps!

What I did to "fix" this was to add the mimetypes missing in windows to an array, and checked if the file extension was in that array, but I'm aware this is a suboptimal fix for the problem.
I think that I will just rollback the apex-publish-static-files as you said, it's easier and don't require manual input in the code nor the need to edit windows registry.

Thanks a lot for your input.

upload ne fonctionne pas avec mon Apex-Nitro
Voilà le message d'errer :

Uploaded: C:\JBMApexNitro\www\src\app1200.css java.sql.SQLException: ORA-20987: APEX - Security Group ID (your workspace identity) is invalid. - Contact your application administrator. ORA-06512: � "APEX_180200.WWV_FLOW_ERROR", ligne 1062 ORA-06512: � "APEX_180200.WWV_FLOW_ERROR", ligne 1429 ORA-06512: � "APEX_180200.WWV_FLOW_SECURITY", ligne 3083 ORA-06512: �

"APEX_180200.HTMLDB_UTIL", ligne 3075 ORA-06512: � ligne 1 Uploaded:

 C:\JBMApexNitro\www\src\app1200.js java.sql.SQLException: ORA-20987: APEX - Security Group ID (your workspace identity) is invalid. - Contact your application administrator. Details about this incident are available via debug id "173683". ORA-06512: � "APEX_180200.WWV_FLOW_ERROR", ligne 1062 ORA-06512: � "APEX_180200.WWV_FLOW_ERROR", ligne 1429 ORA-06512: � "APEX_180200.WWV_FLOW_SECURITY", ligne 3083 ORA-06512: �

"APEX_180200.HTMLDB_UTIL", ligne 3075 ORA-06512: � ligne 1