function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Adeesh maddukuriAdeesh maddukuri 

How to convert data of Versiondata field to create zip file using JSZip

Hi,
 I'm trying to create a page to download multiple files as a zipfile using JSZip. I used rest api to retrive data of versiondata filed. but I'm facing problem to use that to create zip file.  Please find the code below.
  Thanks in Advance.
   
function download(){
        var zip = new JSZip();
        console.log('download function');
        var checkedSize = j$("input[name='doc_ids_group[]']:checked").size();
        console.log('checkedSize = '+checkedSize);
        
        j$("input[name='doc_ids_group[]']:checked").each(function() {
            console.log("inside each loop = "+j$(this).val());
            var id=j$(this).val();
           
             j$.ajax({url: "/services/data/v32.0/sobjects/ContentVersion/"+id+"/VersionData", headers : {
                'Authorization' : "OAuth " + sessionId,
                'Content-Type': ' application/octet-stream',
            }, async: false, success: function(result){
                
                zip.file(id, result, { base64: true }); 
               
            }});
       });
      saveAs(zip.generate({type:"blob"}), 'Download.zip', false);
                            }

 
kumar M 21kumar M 21
I want to see as it is using VisualForce page. If you are giving some code for the above scenario, it will more helpful to me. thanks in advance