Why I can#39;t upload file to Google Cloud Storage that larger than 100KByte through app engine?(为什么我无法通过应用引擎将大于 100KByte 的文件上传到 Google Cloud Storage?)
问题描述
我的项目仅包含简单的文件上传表单和查看它的重定向.我可以上传任何小于 50 KB 的文件,但是当我上传一些大于 100 KB 的文件时,它会从应用引擎抛出 IO 异常.我不确定问题出在哪里.有谁知道如何通过应用引擎中的表单发布来增加我可以上传到谷歌云存储的文件大小?文件大小适当小于 10 MB 即可.任何代码片段将不胜感激.谢谢.
My project contains only simple file upload form and the redirect to view it. I can upload any files less than 50 KB but when I upload some files larger than 100 KB, it throws IO Exception from app engine. I am not sure where the problem is. Do anyone know how to increase the file size that I can upload to Google Cloud storage through the form posting in app engine? file size properly less than 10 MB is OK. Any code snippets would be vhighly appreciated. Thank you.
以下是我的代码:上传.html
Following is my code: upload.html
上传Servlet.java
uploadServlet.java
StorageService.java
StorageService.java
fileserve.java
fileserve.java
web.xml
推荐答案
尝试将第二个 is.read
从:
到:
如果在某些时候你的阅读速度更快,那么数据是可用的,readBytes
设置为 0
并且它永远保持在这个值,因为它基本上是在做 is.read(b, 0, 0)
.
If at some point you are reading faster then data is available, readBytes
is set to 0
and it stays forever at this value, because it's basically doing is.read(b, 0, 0)
.
更好 - 你应该检查是否有数据要写入:
Even better - you should check if there is data to be written:
这篇关于为什么我无法通过应用引擎将大于 100KByte 的文件上传到 Google Cloud Storage?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!