2010-08-05 60 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

相關問題