1 Reply Latest reply on Jan 21, 2016 8:50 AM by jroorda

    Base64 Image passed into an app artifact issue

    jroorda

      This document states that a previewImage " MAY be relative to app gadget.xml, or absolute or base64 encoded image data."

      Understanding App Selection and Embedded Context Reference

       

      but when I try to pass a base64 encoded canvas image:

       

      var img = $("#board")[0].toDataURL();
        osapi.jive.core.container.closeApp({  
        data: {  
            display: {
          type: "image",  
             previewImage: img,  
             label: "This is a tooltip." 
            },  
          target: {  
           type: "embed",  
              view: "embedded"  
          }  
        }  
        });
      

       

      it starts trying to GET the image from the app resources, attempting to use the base64 as a file name. The base64 being so massive it ends up throwing a "414: Request-URI Too Long".

      the GET request is structured like:

      (jive-root-URL)/gadgets/proxy?container=default&refresh=3600&url=(jive-root-URL)/(path-to-app-resources)/(Base64-encoded-image)

       

      inserting the image manually with:

      osapi.jive.core.container.editor().insert("<img src='"+$("#board")[0].toDataURL()+"'/>");
      

      or just pasting it into an image tag works fine, but I need the context sensitive embedded app link.

       

      is there some special thing I need to do to get it to recognize it as Base 64? or somehow for it not to refresh?

        • Re: Base64 Image passed into an app artifact issue
          jroorda

          I found a workaround.

           

          var response = {  
              display: {
                type: "image",  
                previewImage: "images/icon16.png",  //any image works here
                label: "Tooltip" 
              },  
              target: {  
                type: "embed",  
                view: "embedded"  
              }  
            };  
            osapi.jive.core.container.artifacts.create(response, 'app.action.id', function (artifactMarkup) {
                var artifactHTML = $(artifactMarkup.markup);
                artifactHTML.find("img").attr("src",$("#board")[0].toDataURL() );
          
                artifactHTML.attr("__appuuid",artifactHTML.attr("_appuuid"));
                artifactHTML.attr("__view",artifactHTML.attr("_view"));
                artifactHTML.attr("__context",artifactHTML.attr("_context"));
                artifactHTML.attr("__action_id",'app.action.id');
          
                artifactHTML = artifactHTML[0].outerHTML;
                osapi.jive.core.container.editor().insert(artifactHTML);
            });
          

           

          side note, osapi.jive.core.container.artifacts.create() does not create a valid app artifact for some unknown reason, hence the need for the manual attribute editing.