2010-08-05 59 views

回答

-1

在调用数据存储区API之前,将下面的代码放在要接收数据的serlet中。

// 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 
} 
+1

正如OP所说,这是使用App Engine blobstore API,所以这不适用。 – 2010-08-06 10:04:50

+0

从哪里他将调用blobstore API?从一个servlet内?您是否告诉我哪些代码行在App Engine中不适用? – Manjoor 2010-08-06 10:37:19

+1

如果您阅读blobstore(与数据存储区不同)的文档,您会发现以上所有行都不适用 - 您的servlet不接受来自用户的数据,blobstore会这样做。用户提交的表单直接进入blobstore,而不是你的servlet。 http://code.google.com/appengine/docs/java/blobstore/overview.html – 2010-08-06 19:55:48

2

无法从上传太大(尽管这会成为一个好feature request)文件禁止人。你可以做的是检查上传的blob的大小,如果它太大,立即删除它。

+0

我提交了一项功能请求 - http://code.google.com/p/googleappengine/issues/detail?id= 3554 – Kyle 2010-08-06 22:56:19

+2

现在已经实施 – systempuntoout 2011-09-13 07:19:22

相关问题