一個zip文件,這是我的html頁面:有錯誤時,我想讀取存儲在Blob存儲
上傳您的文件在這裏:
<form action="<%= blobstoreService.createUploadUrl("/bootstrap") %>" method="post" enctype="multipart/form-data">
<input type="file" name="myFile">
<input type="submit" value="Submit">
</form>
這是我的控制器:
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, UploadException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
Map<String, BlobKey> blobs = blobstoreService.getUploadedBlobs(request);
BlobKey blobKey = blobs.get("myFile");
if (blobKey == null) {
response.sendRedirect("/");
} else {
BlobKey blobKey2 = new BlobKey(blobKey.getKeyString());
BlobstoreInputStream in = new BlobstoreInputStream(blobKey2);
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(in));
ZipEntry entry = zis.getNextEntry();
while (entry !=null){
String fileName = entry.getName();
int fileSize = (int) entry.getSize();
}
}
我正在上傳一個包含6個zip文件的文件。我可以上傳,但我無法閱讀zip文件。任何更好的解決方案或必須配置的東西?
你有什麼期望,什麼是實際bahaviour(錯誤/問題)? *不能讀*有點模糊.. – 2010-11-09 08:23:44