3

I am Using GWT SDK 2.4.0 Google appengine 1.6.3

I am trying to create a application where a file is uploaded to external repository.

The max size of file is 5 MB.

With help of formPanel, formupload and servlet i send the file to server.

On server Side this file is send to external repository.

fileName = item.getName();
mimetype = item.getContentType();

int len;

        while ((len = stream.read(buffer, 0, buffer.length)) != -1) {
            output.write(buffer, 0, len);
        }
        ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
        Session session =getSession();
    ContentStream contentStream = session.getObjectFactory()
                .createContentStream(fileName, output.size(), mimetype, input);



        FilenetDocument document = new FilenetDocument(fileName);
        Folder folder =getFolderSession();
        folder.createDocument(document.addDocumentProperty(),
                contentStream, VersioningState.MAJOR);

with this procedure i create document in external repository. and on refresh i can see the file on my GWT client GUI.

Now i want to download the same file from external repository. So on server side i wrote this code (FileUtils.download method for downloading from external repositrry.)

System.out.println(" id " +docId);
FileUtils.download(docId,"C:/FilenetDownload",session);  <--line 55

but this gives me Error

PrintStack :

java.lang.NoClassDefFoundError: java.io.FileOutputStream is a restricted class. Please see the Google  App Engine developer's guide for more details.
    at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51)
    at org.apache.chemistry.opencmis.client.util.FileUtils.download(FileUtils.java:241)
    at org.apache.chemistry.opencmis.client.util.FileUtils.download(FileUtils.java:263)
    at com.filenet.server.CmisFileDownload.doPost(CmisFileDownload.java:55)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:35)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:60)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:78)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:363)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)

Plz Can any one explain what is wrong .. or What should i Do..

4

2 回答 2

1

Google App Engine 有一些限制,您可以在此处阅读有关您遇到的问题的更多信息。而不是使用FileUtils.download您应该使用较低级别的 api,然后将内容存储在一些可用的存储位置(普通文件系统不是 GAE 中的选项)。例如,使用BlobStore API

CmisObject object = session.getObject(session.createObjectId(docId));
Document document = (Document) object;
String filename = document.getName();
InputStream stream = document.getContentStream().getStream();
BlobStoreContext context = new BlobStoreContextFactory().createContext("aws-s3", identity, credential);
Map<String, InputStream> map = context.createInputStreamMap("my_content");
map.put(document.getId(), stream);
context.close();
于 2012-06-14T10:07:04.293 回答
1

在应用程序引擎上,您不能直接访问文件系统,这是不允许的。

下面是一个关于如何使用应用引擎 blobstore 上传文件的示例: Blobstore Java API Overview

于 2012-06-14T10:07:11.487 回答