@@ -0,0 +1,1954 @@
+package com.google.sps.tasks;%0A%0Aimport com.google.appengine.tools.cloudstorage.GcsFileOptions;%0Aimport com.google.appengine.tools.cloudstorage.GcsFilename;%0Aimport com.google.appengine.tools.cloudstorage.GcsOutputChannel;%0Aimport com.google.appengine.tools.cloudstorage.GcsService;%0Aimport com.google.appengine.tools.cloudstorage.GcsServiceFactory;%0Aimport com.google.sps.workspace.Workspace;%0Aimport com.google.sps.workspace.WorkspaceFactory;%0Aimport java.io.IOException;%0Aimport java.nio.channels.Channels;%0Aimport java.util.concurrent.ExecutionException;%0Aimport javax.servlet.ServletException;%0Aimport javax.servlet.annotation.WebServlet;%0Aimport javax.servlet.http.HttpServlet;%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0A%0A@WebServlet(%22/tasks/prepareDownload%22)%0Apublic class PrepareDownload extends HttpServlet %7B%0A  WorkspaceFactory workspaceFactory = WorkspaceFactory.getInstance();%0A%0A  @Override%0A  protected void doPost(HttpServletRequest req, HttpServletResponse resp)%0A      throws ServletException, IOException %7B%0A    String body = req.getReader().lines().reduce(%22%22, (accumulator, actual) -%3E accumulator + actual);%0A%0A    String args%5B%5D = body.split(%22,%22);%0A    String workspaceID = args%5B0%5D;%0A    String downloadID = args%5B1%5D;%0A%0A    Workspace w = workspaceFactory.fromWorkspaceID(workspaceID);%0A%0A    GcsService instance = GcsServiceFactory.createGcsService();%0A    GcsFileOptions options = GcsFileOptions.getDefaultInstance();%0A    GcsFilename filename =%0A        new GcsFilename(%22fulfillment-deco-step-2020.appspot.com%22, workspaceID + '/' + downloadID);%0A    GcsOutputChannel outputChannel = instance.createOrReplace(filename, options);%0A%0A    try %7B%0A      w.getArchive().archive(Channels.newOutputStream(outputChannel));%0A%0A      w.updateDownloadURL(downloadID, filename.getObjectName());%0A    %7D catch (InterruptedException %7C ExecutionException e) %7B%0A      // TODO Auto-generated catch block%0A      e.printStackTrace();%0A    %7D%0A  %7D%0A%7D%0A

Add a cloud task to upload an archive to gcs.