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
gengen 

using js zip static resources in apex class

Hi,

 

I need to use JS Zip as static resource and do zip file in apex class.

 

Any help will be appreciated.

 

Thanks

SarfarajSarfaraj

JS Zip is a javascript library. You will not be able to invoke it from apex class. Only place where you can do it is from visualforce page. See if this helps,

http://www.valnavjo.com/blog/compressing-files-in-salesforce/

gengen

Thanks for reply...

 

Here I need to use apex class. Is there any other alternate to make zip file using apex class?

SarfarajSarfaraj

Have you checked the link I gave? That have one sample code you may try. If this does not solve your purpose, please elaborate your requirement.

gengen

Yes Akram. We tried with same example before itself with visual force.

Our requirement is to make the attachments as zip file and need to attach the zip file to case using apex class.

 

Please provide any solution.

Ashish_SFDCAshish_SFDC

Hi Gen, 

 

You mean - the use case is to Create a Zip file and add as an attachment to the case record?

 

Regards,

Ashish

Ashish_SFDCAshish_SFDC

Hi Gen, 

 

This is the js code below might help. 

 

var zip =newJSZip();
zip.file("Hello.txt","Hello World\n");
var img = zip.folder("images");
img.file("smile.gif", imgData,{base64:true});
var content = zip.generate();
location.href="data:application/zip;base64,"+content;

http://stackoverflow.com/questions/16977247/create-zip-file-and-save-it-in-a-particular-location-using-javascript

 

http://viralpatel.net/blogs/create-zip-file-javascript/

 

Regards,

Ashish