Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions java/javaBlobstoreApp/src/gaeexample/blobstore/Upload.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package gaeexample.blobstore;

import java.io.IOException;
import java.util.Map;
import com.google.appengine.api.blobstore.BlobKey;
import com.google.appengine.api.blobstore.BlobstoreService;
import com.google.appengine.api.blobstore.BlobstoreServiceFactory;

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;
import java.io.IOException;
import java.util.Map;

public class Upload extends HttpServlet {

Expand All @@ -22,11 +21,14 @@ public void doPost(HttpServletRequest req, HttpServletResponse res) throws Servl
BlobKey blobKey = blobs.get("myFile");
BlobKeyCache bc = BlobKeyCache.getBlobKeyCache();

String contextPath = req.getScheme().toString() + "://" + req.getServerName().toString() + ":" + String.valueOf(req.getServerPort());

if (blobKey == null)
System.out.println("blobkey is null");
else {
System.out.println("blobkey is " + blobKey.getKeyString());
bc.add(blobKey);
res.sendRedirect("/serve.jsp?blob-key=" + blobKey.getKeyString() + "&fromUpdate=1");
res.sendRedirect(res.encodeRedirectURL(contextPath + "/serve.jsp?blob-key=" + blobKey.getKeyString() + "&fromUpdate=1"));
}
}
}
}
2 changes: 1 addition & 1 deletion java/javaBlobstoreApp/war/WEB-INF/appengine-web.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>simpleBlobstore</application>
<application>javaBlobstoreApp</application>
<version>1</version>
<threadsafe>true</threadsafe>

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.