package com.google.sps.servlets;

import com.google.appengine.api.blobstore.BlobKey;
import com.google.appengine.api.blobstore.BlobstoreServiceFactory;
import java.io.IOException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/blob-serve")
public class BlobServeServlet extends HttpServlet {
  private static final String BLOB_KEY = "key";

  @Override
  public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
    BlobstoreServiceFactory.getBlobstoreService().serve(new BlobKey(request.getParameter(BLOB_KEY)), response);
  }
}

@@ -597,115 +597,337 @@
     
-BlobstoreServiceFactory.getBlobstoreService().serve(new BlobKey(request.getParameter(BLOB_KEY)), response);
+String blobKeyValue = request.getParameter(BLOB_KEY);%0A    if (!blobKeyValue.isEmpty()) %7B%0A      BlobstoreServiceFactory.getBlobstoreService().serve(new BlobKey(blobKeyValue), response);%0A    %7D else %7B%0A      response.sendError(%0A          HttpServletResponse.SC_BAD_REQUEST, %22Error with serving image: blob key does not exist%22);%0A    %7D
 %0A  %7D

Fix blobstore backend