cancel
Showing results for 
Search instead for 
Did you mean: 

Detecting https protocol in URL

fkoenig
Champ in-the-making
Champ in-the-making
I'm setting up access to an Alfresco Share system through a firewall via an https proxy on an Apache server to allow access to Share to external collaborators.

As others, I encountered the problem that multiple file upload with Flash is not working (at least not with FF 3.6 and IE 8 on Windows Vista which I use) ( http://forums.alfresco.com/en/viewtopic.php?f=47&t=23840&p=78012&hilit=upload+flash#p78012 ).

One work-around that I found it to modify tomcat/webapps/share/components/upload/file-upload.js to force simple html upload and tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/upload/html-upload.get.properties to hide the tip concerning installing Flash.

This has the inconvenient that it blocks multiple uploads also for on-site users who are allowed to access Share in http and who will be in our case the main document contributors. I would like to detect the protocol of the current URL and use this information to selectively block multiple uploads. Is there an  attribute that I could use in the Javascript ?

Thanks for any help on this.
2 REPLIES 2

fkoenig
Champ in-the-making
Champ in-the-making
I found the solution: the attribute I was looking for is window.parent.document.location.protocol .

- To use Flash multiple file upload only if the protocol is http , modify the file tomcat/webapps/share/components/upload/file-upload.js to replace (twice in the file: line 86 and line 219 (for Alfresco 3.1 and 3.2)):
if (this.hasRequiredFlashPlayer)
by:
 if (this.hasRequiredFlashPlayer && (window.parent.document.location.protocol == "http:"))
and (near line 223)
         else
         {
            this.showConfig.uploadURL = this.showConfig.htmlUploadURL;
         }
by
         else
         {
            this.showConfig.mode = this.MODE_SINGLE_UPLOAD;
            this.showConfig.uploadURL = this.showConfig.htmlUploadURL;
         }

To remove the tip about installing Flash, edit tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/upload/html-upload.get.properties and refresh the web scripts.

mikeh
Star Contributor
Star Contributor
You can shorten all that to just "location.protocol" as the browser populates the root namespace with window's top-level properties anyway (or "window.location.protocol" to be JSLint-friendly). There's often no point trying to use "window.parent" or "top." etc. because if you're framed, the browser will probably prevent you from requesting those properties.

Thanks for sharing your customisation!
Mike