package com.google.launchpod.servlets;

import com.google.appengine.api.blobstore.BlobstoreService;
import com.google.appengine.api.blobstore.BlobstoreServiceFactory;
import com.google.appengine.api.blobstore.BlobInfo;
import com.google.appengine.api.blobstore.BlobInfoFactory;
import com.google.appengine.api.blobstore.BlobKey;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@SuppressWarnings("serial")
@WebServlet("/form-handler")
public class FormHandlerServlet extends HttpServlet {

  @Override
  public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
    
    
  }

  private String getUploadedFileUrl(HttpServletRequest req, String inputName){
    BlobstoreService blobstore = BlobstoreServiceFactory.getBlobstoreService();
    Map<String, List<BlobKey>> blobs = blobstore.getUploads(req);
    List<BlobKey> keys = blobs.get(inputName);

    return "";
  }
}

@@ -79,28 +79,20 @@
 ore.Blob
-storeService
+Info
 ;%0Aimport
@@ -127,36 +127,28 @@
 obstore.Blob
-storeService
+Info
 Factory;%0Aimp
@@ -182,36 +182,35 @@
 i.blobstore.Blob
-Info
+Key
 ;%0Aimport com.goo
@@ -237,35 +237,36 @@
 obstore.Blob
-InfoFactory
+storeService
 ;%0Aimport com
@@ -305,40 +305,174 @@
 Blob
-Key;%0A%0Aimport java.io.IOException
+storeServiceFactory;%0Aimport com.google.appengine.api.images.ServingUrlOptions;%0A%0Aimport java.io.IOException;%0Aimport java.net.MalformedURLException;%0Aimport java.net.URL
 ;%0Aim
@@ -1203,16 +1203,372 @@
 Name);%0A%0A
+    //When there is nothing uploaded%0A    if(keys.isEmpty() %7C%7C keys == null)%7B%0A      return null;%0A    %7D%0A    //Get first input from form%0A    BlobKey key = keys.get(0);%0A%0A    //when user does not select form%0A    BlobInfo blobInfo = new BlobInfoFactory().loadBlobInfo(key);%0A    if(blobInfo.getSize() == 0)%7B%0A      blobstore.delete(key);%0A      return null;%0A    %7D%0A%0A
     retu

extend test casese for creating an upload URL, and generating url from file