Use of sap.m.upload.UploadSet with ClearFileSystem

  • Jens Schreyer
        Has successfully completed the online course Basics (100)
      1 month ago #63377

      Dear all,

      is it possible to use the sap.m.upload.UploadSet with the Simplifier content repository plugin (ClearFileSystem)?

      If so, which prerequisites must be met?

      Thanks in advance for your support.

      Best regards

      Jens Schreyer

      Daniel Bieberstein
          Has successfully completed the online course Introduction
          Has successfully completed the online course Intermediate (200)
          Has successfully completed the online course Advanced (300)
          Has successfully completed the online course Basics (100)
          Has successfully completed the online course Advanced (310)
          Has successfully completed the online course Advanced (320)
        2 weeks ago #63921
        Up
        0
        Down
        ::

        Hey Mr. Schreyer,

        There’s no limitation on the upload set to be used with the content repository.

        You can use the uploadeComplete event of the upload set to read the file and get the base64 value which then can be used in the contentFileAdd method as data to be uploaded to the content repository.

        The following script will return the b64 value of the uploaded file when attached to the “uploadComplete” event of the upload set:

        var reader = new FileReader();
        var file = oEvent.getParameters(“files”).item.getFileObject();

        reader.onload = function(e) {
        var b64 = e.target.result;
        console.log(“b64:”, b64); // b64 is the file – can be used to be uploaded in the content repo
        };

        reader.onerror = function(e) {
        sap.m.MessageToast.show(“error”);
        };
        reader.readAsDataURL(file);

        You can fine more information on reading the file here:

        https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL

        More information on the content repository can be found here:

        How to use Simplifier Content Repository Plugin


        and here

        Content Repository

        Best regards,

        Daniel

        • This reply was modified 2 weeks ago by Daniel Bieberstein.
        Jens Schreyer
            Has successfully completed the online course Basics (100)
          2 weeks ago #63939
          Up
          0
          Down
          ::

          Many thanks Daniel for the detailed information.

          I’ll try to implement it that way.

          Armin Winkler
              Has successfully completed the online course Introduction
              Has successfully completed the online course Intermediate (200)
              Has successfully completed the online course Advanced (300)
              Has successfully completed the online course Basics (100)
            1 week ago #64021
            Up
            0
            Down
            ::

            Hi Jens,

             

            one short addition to Daniel’s reply: Be aware that the script code provided by him actually returns a data URL instead of the sole file content encoded as base64 string. However, the Content Repository plugin slot ‘contentFileAdd’ only accepts the base64 encoded content without the data prefix and mime type given in a data URL. Therefore, you’d have to remove that part from the data URL output given from the FileReader to extract only the base64 value. You could achieve this by changing the related line of code into the following:

             

            var b64 = e.target.result.split(“,”).pop();

             

            Kind regards,

             

            Armin

             

          Viewing 4 posts - 1 through 4 (of 4 total)

          You must be logged in to reply to this topic.