+ Start a Discussion
Eriko YamamuraEriko Yamamura 

How can I make zip file?

I would like to create a custom action to download record attachments as a zip in LightningExperience.
I created a controller and Visualforce to download attachments obtained using zippex https://github.com/pdalcol/Zippex.
public class ImageZipController {
  public final ParentObject__c parent {get; set;}
  private Id parentObjId;
  public ImageZipController(ApexPages.StandardController stdController) {
      this.order = (order__c)stdController.getRecord();
    public PageReference downloadAttachments(){
	orderId = order.Id;

    String objectId = parentObjId;
    String docName =  'test.zip'; 
    List<Attachment> attachments = [SELECT Name, Body FROM Attachment WHERE ParentId = :objectId];
    System.debug('>>> attachments ' + attachments.size());
    Zippex sampleZip = new Zippex();
    for(Attachment file : attachments) {
      sampleZip.addFile('folder/' + file.Name, file.Body, null);
      Document doc = new Document();
      doc.FolderId = UserInfo.getUserId();
      doc.Name = docName;
      doc.Body = sampleZip.getZipArchive();
      insert doc;
      System.debug('>>> doc ' + doc.Id);
      return new PageReference('/servlet/servlet.FileDownload?file=' + doc.Id);
    } catch ( Exception ex ) {
      System.debug('>>> ERROR ' + ex);
    return null;


But even small files will give errors.
Error: System.LimitException: Apex CPU time limit exceeded

I researched myself and found that using @future can avoid it, but I don't know what code to write.
I do not have enough knowledge as a developer.
Please Help me.
Ranjan Kumar 78Ranjan Kumar 78
BIO is a digital marketing agency. Our strength is business to business digital marketing strategy. We help clients generate leads and sales, build brand equity, reach a wider audience, solve their unique marketing challenges, and track their success. In short, our business is building your business. (https://www.whatsapp-dp-images.in/)
nitesh patelnitesh patel
IPL 2020 is going to be held in April-May 2020. You can see IPL 2020 schedule (https://iccworldcupcricket2019.com/vivo-ipl-2020-time-table-schedule-match-list-pdf/) and other cricket news at iccworldcupcricket2019.com.
Also see: livethetech.com
nitesh patelnitesh patel
Want to watch movies online free? I have made a list of more than 20 websites where you can watch movies online free without signup (https://www.livethetech.com/sites-to-watch-movies-online-free-no-signup/). Check those sites to watch movies free. If you want to download youtube videos free then check dwnldit.com
Naveen kumar 974Naveen kumar 974
Did you know how to download ipl schedule 2020 for all the upcoming ipl cricket match of Indian Premier League 2020?
Naveen kumar 974Naveen kumar 974
Check out all the today’s sports matches including One Day International cricket matches, Test cricket matches and IPL cricket T20 matches of all the seasons.
Stars BiodataStars Biodata
For makeing Zip file you can try many tools availble on internet.

Visit my blog - starsbiodata.com (https://starsbiodata.com/)

TamilMV 2020 – Download Tamil, Telugu, Malayalam, Kannada Hindi Dubbed Movies For Free (https://starsbiodata.com/tamilmv/)

Bolly4u 2020 – Download Tamil, Telugu, Malayalam, Kannada Hindi Dubbed Movies For Free (https://starsbiodata.com/bolly4u/)
sonu kumar 78sonu kumar 78
Check out the detailed guide to buy a freezer before selecting any mini freezer (https://www.minifreezershop.com/)
sonu kumar 78sonu kumar 78
are you want to set your whatsapp status with a wonerful video, check out whatsapp status video (https://www.whatsappstatusvideos.co/)
sonu kumar 78sonu kumar 78
here are the lovely good evening images (https://www.imagesdownloadhd.com/good-evening/)
raghu ram 114raghu ram 114
bes tkutty movies collection  to download tamil telugu (https://grabtrending.com/kuttymovies-collection-tamil-movies-download/)
marugujarat jobsmarugujarat jobs
Maru gujarat is one of the free job portal in gujarat,maru gujarat,marugujarat, ojas, mahanmk, nmk, ojas website(http://marugujarat.link/gujarati-news-papers/) and , gujarati job, gujarati news paper at http://marugujarat.link.

http://www.49westwineandspirits.com/ (http://www.49westwineandspirits.com)
Emaan NaaumaanEmaan Naaumaan
Creating Zip files is never difficult but it depends upon the system that you are using. If I am using Windows pc and i have 4 folders lets say we name them like Webcric (https://icccricketworldcup2019.net/webcric-live-ipl-2020/), Watchcric (https://icccricketworldcup2019.net/watchcric/), IPL 2020 Schedule (https://icccricketworldcup2019.net/ipl-2020-schedule-pdf-download/), MyliveCricket (https://icccricketworldcup2019.net/mylivecricket/), what will i do? I will select and right-click and choose the option of the make a zip file. 
kunal shah 14kunal shah 14
 ipowatch (http://ipowala.in) provides ipo gmp (https://ipowala.in/ipo-grey-market-premium-gmp/) grey market premium,ipo grey market,ipo grey market premium,gmp ipo,gray market premium,chittorgarh ipo grey market,ipo grey market price. 
Matthew GiannelisMatthew Giannelis
Creating zip files before uploading them to public clouds saves a lot of space on the server over time. IBM has a salesforce system intergration for cloud computing (https://www.techbusinessnews.com.au/ibm-cloud-security-and-solutions/) solution with built in security that can detect zipped files with security issues.
Matthew GiannelisMatthew Giannelis
You can also find heaps of other instructional options for many other zip and compression software on Australian tech news websites (https://www.techbusinessnews.com.au)