要将文件上传到我在 google appengine 上的项目目录中,我正在尝试使用apache 流 API和Google App Engine Virtual File System。这是我到目前为止能够做的事情:
String path = request.getParameter("Data");
PrintWriter writer = response.getWriter();
try {
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
if( !isMultipart ) {
writer.println("File cannot be uploaded !");
}
else {
ServletFileUpload upload = new ServletFileUpload();
FileItemIterator iter = upload.getItemIterator(request);
List list = null;
while(iter.hasNext()) {
FileItemStream item = iter.next();
String name = item.getFieldName();
String fileName = item.getName();
InputStream stream = item.openStream();
if(item.isFormField()) {
// Process regular form field (input type="text|radio|checkbox|etc", select, etc).
} else {
GaeVFS.setRootPath( getServletContext().getRealPath("/") );
FileSystemManager fsManager = GaeVFS.getManager();
//....NOW WHAT....
}
}
}
我被困在 else 块中。现在如何进行?我必须将文件写入项目中名为uploads的目录。