package com.adamtron.blobup;
import javax.servlet.http.HttpServlet;
import java.io.IOException;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.google.appengine.api.blobstore.BlobKey;
import com.google.appengine.api.blobstore.BlobstoreService;
import com.google.appengine.api.blobstore.BlobstoreServiceFactory;
@SuppressWarnings("serial")
public class BlobUploadServlet extends HttpServlet {
private BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/plain");
res.getWriter().println("BlobServe!");
}
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
java.util.Map<java.lang.String,java.util.List<BlobKey>> keys = blobstoreService.getUploads(req);
BlobKey blobKey = keys.get("myFile").get(0);
res.sendRedirect("/blobup/listblobs.jsp");
}
}