1

I used the methods suggested here: Creating ZIP archives in Google App Engine ( Java)
And here How to create a zip archive containing google cloud storage objects within appengine java app? to return a zip file, the problem I'm having is that the response is bigger than the allowed ~30M. What is the best practice to deal with it?

Community
  • 1
  • 1
RCB
  • 2,253
  • 2
  • 25
  • 49

1 Answers1

1

Most optimal way will be saving to Storage Bucket, and then serve it from there.

It also allows you to:

  • prepare file from a TaskQueue job, which is not limited to 60 seconds so you can process much more data, handle errors, etc
  • give user ability to pause/resume download, use a download manager, etc, w/o forcing your frontend to start the job from the beginning each time

Basically i'm suggesting:

  1. give user an TicketId for backend job
  2. send task to TaskQueue
  3. prepare data in this backend job, upload to Storage Bucket, set TicketId as done
  4. browser waits until TicketId is marked as done (AJAX of Channel API)
  5. then a special servlet gives this file, from a Storage

There're two options to serve this file later:

(optimal) Give a link directly to Storage object:

or by using Blobstore:

BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
BlobKey blobKey = blobstoreService.createGsBlobKey("/gs/<bucket>/<object>");
blobstoreService.serve(blobKey, resp); //where resp is your HttpServletResponse
Igor Artamonov
  • 35,450
  • 10
  • 82
  • 113
  • If the ZIP file is big won't I have the same issues with the servlet from step 5? – RCB Jun 13 '16 at 06:24
  • 1
    no, if you're not copying it manually through servlet. see answer update – Igor Artamonov Jun 13 '16 at 06:58
  • My task gets cancelled because I get timeout accessing the GCService. The zip's are huge. – RCB Jun 16 '16 at 14:55
  • Oh, you mean 10 minutes is not enough? try to use _manual_ or _basic_ scaling instead of _automatic_, it gives up to 24 hours for a task. See https://cloud.google.com/appengine/docs/java/an-overview-of-app-engine#scaling_types_and_instance_classes – Igor Artamonov Jun 16 '16 at 15:00