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?
Asked
Active
Viewed 423 times
1
1 Answers
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:
- give user an TicketId for backend job
- send task to TaskQueue
- prepare data in this backend job, upload to Storage Bucket, set TicketId as done
- browser waits until TicketId is marked as done (AJAX of Channel API)
- 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:
- https://storage.googleapis.com/<bucket>/[<object>]
- https://<bucket>.storage.googleapis.com/[<object>]
- https://yourdomain.if.set.for.the.bucket/[<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
-
1no, 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