I'm learning AWS and am having problem with a simple upload servlet. As far as I can see everything is fine except for the getUploadedBlobs(req); has a line though it in eclipse. This is the message given
Deprecated. Use getUploads instead. Note that getUploadedBlobs does not handle cases where blobs have been uploaded using the multiple="true" attribute of the file input form element. Returns the BlobKey for any files that were uploaded, keyed by the upload form "name" field. This method should only be called from within a request served by the destination of a createUploadUrl call.
I then get a server error when I try to upload a file. I found a tutorial site and my code seems a complete match.
https://cloud.google.com/appengine/docs/java/blobstore/
I've been scratching my head over this for ages now and can't see the problem, any help would be really appreciated.
Deprecated. Use getUploads instead. Note that getUploadedBlobs does not handle cases where blobs have been uploaded using the multiple="true" attribute of the file input form element. Returns the BlobKey for any files that were uploaded, keyed by the upload form "name" field. This method should only be called from within a request served by the destination of a createUploadUrl call.
I then get a server error when I try to upload a file. I found a tutorial site and my code seems a complete match.
https://cloud.google.com/appengine/docs/java/blobstore/
I've been scratching my head over this for ages now and can't see the problem, any help would be really appreciated.
Code:
package ie.itb.l.a
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;
public class Upload extends HttpServlet
{
private static final long serialVersionUID = 1L;
private BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
@Override
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
@SuppressWarnings("deprecation")
Map<String, BlobKey> blobs = blobstoreService.getUploadedBlobs(req);
BlobKey blobKey = blobs.get("myFile");
if (blobKey == null)
{
res.sendRedirect("/");
}
else
{
res.sendRedirect("/serve?blob-key=" + blobKey.getKeyString());
}
}
}