apex-nitro
apex-nitro copied to clipboard
Apex-nitro upload is not considering .js files
Issue Description
apex-nitro upload is not considering .js files
APEX Nitro Version
v5.0.2
Operating System
Windows 10
Node Version
v14.15.1
Browser
Chrome Version 87.0.4280.66 (Official Build) (64-bit)
APEX Version
20.2
Web Server
ORDS 19.2.0.r1991647, Tomcat 8
C:\srcHeroApexIMT\trunk\Hero-Applications\Applications\IMT\imt-apex-nitro>apex-nitro upload
APEX Nitro
Your project is using Basic mode, so there is nothing to build.
Change your project to Pro mode or execute apex-nitro launch.
...Now uploading!
Uploading to 500 - Application Static Files...
SQLcl: Version 20.2 Production en mar dic 15 16:57:46 2020
Copyright (c) 1982, 2020, Oracle. Todos los derechos reservados.
Conectado a:
Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0
Uploaded: C:\srcHeroApexIMT\trunk\Hero-Applications\Applications\IMT\imt-apex-nitro\src\app-icon.css
Uploaded: C:\srcHeroApexIMT\trunk\Hero-Applications\Applications\IMT\imt-apex-nitro\src\app-icon.svg
Uploaded: C:\srcHeroApexIMT\trunk\Hero-Applications\Applications\IMT\imt-apex-nitro\src\hero-logo.png
Uploaded: C:\srcHeroApexIMT\trunk\Hero-Applications\Applications\IMT\imt-apex-nitro\src\HeroIMT.css
Uploaded: C:\srcHeroApexIMT\trunk\Hero-Applications\Applications\IMT\imt-apex-nitro\src\hero_logo_2018.png
SQL>
Desconectado de Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0
Files were uploaded successfully.
Can you tell me your java version please?
~/ $ 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)
Thanks a lot for your help Vincent!
C:\WINDOWS\system32>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 this the same problem of this issue over the apex-publish-static-files project?
Hi all,
We're in a hurry in the project and I've implemented a terrible workaround (thanks to @marvinamorim analysis) and now it works:
apex-publish-static-files\lib\distUpload.js:
/* get the mime type from a file name before loading it in the database */
helpers.getMimeTypeFromFile = function (fileName) {
try {
var extension;
var i = fileName.toString().lastIndexOf('.');
if (i > 0) {
extension = fileName.toString().substring(i);
}
var mimeType = java.nio.file.Files.probeContentType(java.nio.file.Files.createTempFile("dummy", extension));
if (extension==='.js') {
mimeType = 'application/javascript';
}
return mimeType;
} catch (e) {
ctx.write(e);
}
};
Regards, Jose.
We have the same issue. It actually fails to set proper mime type for all filetypes (in our case .js .css .png), we did a dirty fix on the DB side
SET TRANSACTION READ WRITE;
update APEX_200200.WWV_FLOW_COMPANY_STATIC_FILES
set MIME_TYPE = 'application/javascript' WHERE file_name like '%.js';
update APEX_200200.WWV_FLOW_COMPANY_STATIC_FILES
set MIME_TYPE = 'text/css' WHERE file_name like '%.css';
update APEX_200200.WWV_FLOW_COMPANY_STATIC_FILES
set MIME_TYPE = 'image/png' WHERE file_name like '%.png';
COMMIT;
A few of my colleagues had the same problem so one of them did some digging and came up with the reason and a possible solution. See https://github.com/vincentmorneau/apex-publish-static-files/issues/21#issuecomment-771033106 for this
Hi all,
it appears the none of the mime-types are not honored when uploading. CSS, JS, Fonts, Images. They all get uploaded as text/txt.
Above SQL statement is a workaround hack that we have to apply manually.
@JoseArostegui : I don't think it's a terrible workaround. :-)
I think an update in the helpers.getMimeTypeFromFile could easily fix the problem. It just needs to honor all types that are out there.
/* get the mime type from a file name before loading it in the database */
helpers.getMimeTypeFromFile = function (fileName) {
try {
var extension = 'text/txt';
var i = fileName.toString().lastIndexOf('.');
if (i > 0) {
extension = fileName.toString().substring(i);
}
var mimeType = java.nio.file.Files.probeContentType(java.nio.file.Files.createTempFile("dummy", extension));
if (extension==='.js') {
mimeType = 'application/javascript';
}
if (extension==='.png') {
mimeType = 'image/png';
}
if (extension==='.css') {
mimeType = 'text/css';
}
return mimeType;
} catch (e) {
ctx.write(e);
}
};
Any chance this can be fixed and distributed into a new release?