Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-4923

zEmbedded download fails

    XMLWordPrintable

    Details

      Description

      Steps to Reproduce

      Run download in ZK embedded application

      Current Result

      Download is performed on the outer application's context

      (if the main website https://myapp/ is embedding https://mzkapp/, the download url will looks like https://myapp/zkau/.../myfile.txt instead of https://mzkyapp/zkau/.../myfile.txt)  

      fails with 404 since file doesn't exist on the outer webapp

      Expected Result

      Calling Filedownload.save(media) downloads the media, even in embedded app

      Debug Information

       

      Workaround

      function retrieveZkUrlContext(){
        		if(!zEmbedded || !zEmbedded._zk_loadedResource){
        			return;
        		}
       		var resource = Object.keys(zEmbedded._zk_loadedResource)[0];
       		return resource.split("zkau")[0];
       	}
      	zk.afterLoad("zk", function () {
      	    var _xcmd0 = {};
      	    zk.override(zAu.cmd0, _xcmd0, {
      	        download: function(url) {
      	        	var newUrl = null;
      	        	if( retrieveZkUrlContext()){
      		        	newUrl = retrieveZkUrlContext() + "zkau" + url.split("zkau")[1];
      	        	} else{
      	        		newUrl = url;
      	        	}
      				var result = _xcmd0.download.apply(this, [newUrl]);
      				return result;
      	        }
      	     });
      	});
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              DevChu DevChu
              Reporter:
              MDuchemin MDuchemin
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: