Sunday, 18 August 2013

GAE: File uploading failing on live

GAE: File uploading failing on live

I've created a brand new project on Google App Engine using the 1.8.2 SDK.
I'm trying to build a file uploader, locally the file uploader works fine,
after deploying it and attempting an upload, I'm getting the following
error:
POST
http://test2.website.appspot.com/_ah/upload/AMmfu6bj08dli8J-kL3D_xdt…cQ6YCoQx3NC1s4If-C2J1moqV7Lg/ALBNUaYAAAAAUhExcSNKV9D3-0TadzZaCtssmKinnP5T/
503 (Service Unavailable)
_ah/upload/AMmfu6bj08dli8J-kL3D_xdthBPw4H3jir2X86RQ3dQPlV5LukvcH9t7OP8dK147…6YCoQx3NC1s4If-C2J1moqV7Lg/ALBNUaYAAAAAUhExcSNKV9D3-0TadzZaCtssmKinnP5T/:1
I've enabled billing on both GAE and Google Cloud Storage.
The code I'm using to generate the upload url is as follow:
public static String getUploadUrl(HttpServletRequest req) {
String bucket = "website-uploads";
BlobstoreService blobstoreService =
BlobstoreServiceFactory.getBlobstoreService();
UploadOptions uploadOptions =
UploadOptions.Builder.withGoogleStorageBucketName(bucket);
return blobstoreService.createUploadUrl("/upload", uploadOptions);
}
I'm using normal servlets to handle the multipart post:
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException {
if (!SH.isLoggedIn(req)){
SH.redirectPage(req, res, 200, "/login");
return;
}
BlobstoreService blobstoreService =
BlobstoreServiceFactory.getBlobstoreService();
Map<String, List<BlobKey>> blobs = blobstoreService.getUploads(req);
List<BlobKey> keys = blobs.get("file");
if (keys != null && keys.size() > 0) {
BlobKey blobKey = keys.get(0);
SH.setAttribute(req, "blobKey", blobKey.getKeyString());
} else {
SH.setAttribute(req, "uploadError", "An error occurred while
uploading ...");
}
SH.setAttribute(req, "uploadUrl", getUploadUrl(req));
SH.gotoPage(req, res, 200, JSP.pageUpload);
}
And then my form doind the submit:
<form id='uploadForm' action="${uploadUrl}" method="POST"
enctype="multipart/form-data" >
<input id="imageUploader" name="file" type="file" />
<input type="submit" name="submitBtn" value="Upload" />
</form>
Is there anything obvious that is wrong with my code or is this something
Google needs to fix? If so, how do I notify them of the problem?

No comments:

Post a Comment