Hi,
I have uploaded html file in documentlibrary.
When I use View in Browser , it is ignoring html style and display plain text only.
it is loading in browser so It should display like normal html file we are opening in browser with style.
Unfortunately, Alfresco Share has a very aggressive "HTML stripping" functionality to prevent malicious content / hijacking in HTML files, which applies to the "view in browser" feature for HTML files. Essentially, the style markup is transparently removed from the HTML when it is being loaded from the backend, resulting in the plain-text-like display. In one of my modules I circumvent that URL-based handling by mapping a default functionality to a custom URL, and then reconfigure the "view in browser" action in a customer system to use that non-processed URL instead of the default.
Please help to achieve that scenario.
How Can I change code?
Is it proper way to override bean?
Hi Axel! thanks for the input.
I am having the same issue. Could you please point me on the right direction on how to avoid this filters in order for the html files to load correctly?
Thanks!
David
i hope can fix the issue please refer to the WebLogic training tutorial.
I do not advocate changing Alfresco code for this. I primarily advocate mapping the download web script to a different URL (similar to how I do it via a custom web script mapped to a bean extended from the same parent ), and then reconfiguring the view-content action to use a different href that maps to the custom web script (the default viewUrl is calculated here using https://github.com/Alfresco/share/blob/master/share-services/src/main/resources/alfresco/templates/w... ). E.g. for my web script I would have to configure the following href pattern:
/share/proxy/alfresco/acosix/api/utility/node/slingshot/{node.nodeRef.storeType}/{node.nodeRef.storeId}/{node.nodeRef.id}
If you wanted to eliminate the /share/proxy/alfresco/ prefix and use constants with deployment specific values (technically both "share" and "alfresco" in the prefix could be different in some deployments, but 99.99% stick to the default, and most people probably don't know how it could be changed to begin with), you would have to write a JavaScript based action, register and use it as documented on docs.alfresco.com.
I did the same thing but I am getting error like
org.springframework.extensions.webscripts.WebScriptException - 04130115 Web Script format '' is not registered |
Step 1 : this path I have created given .xml file with same content for test.
Step 2: Created bean in webscript-context.xml
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'> <beans> <bean id="webscript.de.acosix.acosix-utility.slingshot-content.get" parent="webscript.default" /> </beans>
Step 3 : Create javascript base custom action and opening url.
(function() { YAHOO.Bubbling .fire("registerAction", { actionName : "viewInBrowser", fn : function viewInBrowser(file) { console.log(file); var contentUrl = Alfresco.constants.PROXY_URI+"acosix/api/utility/node/slingshot/"+file.nodeRef.replace(":/","")+"/"+file.fileName; window.open(contentUrl); } }); })();
Do I need to override all the bean of this file?
You need to set the parent of the bean to "webscript.org.alfresco.slingshot.download.get". This is done by a dynamic component in my module, but you may simply set it on the existing bean without the dynamic handling (that handling is only in place to be compatible with Alfresco installations where Share Services is not installed)
I did the same thing but getting NullPointerException.
2021-05-15 12:46:57,840 ERROR [extensions.webscripts.AbstractRuntime] [http-bio-9090-exec-2] Exception from executeScript - redirecting to status template error: null java.lang.NullPointerException at org.alfresco.repo.web.scripts.content.ContentGet.execute(ContentGet.java:108) at org.alfresco.slingshot.web.scripts.SlingshotContentGet.execute(SlingshotContentGet.java:114) at org.alfresco.repo.web.scripts.RepositoryContainer$3.execute(RepositoryContainer.java:505) at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:457) at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:580) at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:649) at org.alfresco.repo.web.scripts.RepositoryContainer.executeScriptInternal(RepositoryContainer.java:421) at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:301) at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:378) at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209) at org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:132) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)
Here I am attching Demo .
Here is bean .
Action Name is View In Browser HTML
Am i doing anything wrong?
@afaust Any Suggestion?
This error is due to the fact that you are calling the web script without any URL parameters. The implementation expects that there is at least one parameter (e.g. the `?a=true` to trigger sending the response with attachment disposition), and does not check for null - so you could say you are simply running into a bug / implementation mistake by an Alfresco developer here.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.