What can I do to limit the size of a file that can be uploaded? I know I can limit it client side with SWFUpload, but how can I limit it server side?
How do I protect against someone uploading a 1GB file and eating up my quota?
What can I do to limit the size of a file that can be uploaded? I know I can limit it client side with SWFUpload, but how can I limit it server side?
How do I protect against someone uploading a 1GB file and eating up my quota?
Put the code below in serlet where you are recieving data, before calling datastore API.
// Determine the HTTP method
long maxSize = 1024*1024 * 50; //Limit 50 MB
boolean isPostMethod = request.getMethod().equals("POST");
// Verify the content length
int contentLength = request.getContentLength();
if (isPostMethod && (contentLength < 0 || contentLength > maxSize))
//posted data size is not in acceptable range
else {
// Process Data
}
You can't prohibit people from uploading files that are too large (though this would make a good feature request). What you can do is check the size of the uploaded blob, and immediately delete it if it's too big.