2013-02-22 84 views
3

我得到當地下面的錯誤以及生產。我正在使用SDK1.6.3。 @production我還在「google api console」的Team標籤中添加了[email protected]產生java.io.IOException在com.google.appengine.api.files.FileServiceImpl.translateException(FileServiceImpl.java:586)

FileService fileService = FileServiceFactory.getFileService(); 
    GSFileOptionsBuilder optionsBuilder = new GSFileOptionsBuilder() .setBucket(BUCKETNAME) .setKey(FILENAME) .setMimeType("text/html") .setAcl("public_read") .addUserMetadata("myfield1", "my field value"); 
    AppEngineFile writableFile = fileService.createNewGSFile(optionsBuilder.build()); 

這是我的代碼,我在

AppEngineFile writableFile = fileService.createNewGSFile(optionsBuilder.build()); 

得到錯誤我用上面的代碼並獲得以下錯誤..

java.io.IOException 
    at com.google.appengine.api.files.FileServiceImpl.translateException(FileServiceImpl.java:586) 
    at com.google.appengine.api.files.FileServiceImpl.makeSyncCall(FileServiceImpl.java:561) 
    at com.google.appengine.api.files.FileServiceImpl.create(FileServiceImpl.java:479) 
    at com.google.appengine.api.files.FileServiceImpl.createNewGSFile(FileServiceImpl.java:149) 
    at com.yamaha.StogareTestServlet.doGet(StogareTestServlet.java:34) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) 
    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.headerComplete(HttpConnection.java:923) 
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547) 
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) 
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) 
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409) 
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582) 
Caused by: com.google.apphosting.api.ApiProxy$ApplicationException: ApplicationError: 705: Parameter x-goog-meta-myfield1 is not supported 
    at com.google.appengine.api.files.dev.LocalFileService.throwError(LocalFileService.java:196) 
    at com.google.appengine.api.files.dev.FileMetadata.checkParameters(FileMetadata.java:211) 
    at com.google.appengine.api.files.dev.GSFile.create(GSFile.java:98) 
    at com.google.appengine.api.files.dev.LocalFileService.create(LocalFileService.java:217) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.callInternal(ApiProxyLocalImpl.java:498) 
    at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.call(ApiProxyLocalImpl.java:452) 
    at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.call(ApiProxyLocalImpl.java:430) 
    at java.util.concurrent.Executors$PrivilegedCallable$1.run(Executors.java:463) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.util.concurrent.Executors$PrivilegedCallable.call(Executors.java:460) 
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:138) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) 
    at java.lang.Thread.run(Thread.java:619) 

Caused by: 
com.google.apphosting.api.ApiProxy$ApplicationException: ApplicationError: 705: Parameter x-goog-meta-myfield1 is not supported 
    at com.google.appengine.api.files.dev.LocalFileService.throwError(LocalFileService.java:196) 
    at com.google.appengine.api.files.dev.FileMetadata.checkParameters(FileMetadata.java:211) 
    at com.google.appengine.api.files.dev.GSFile.create(GSFile.java:98) 
    at com.google.appengine.api.files.dev.LocalFileService.create(LocalFileService.java:217) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.callInternal(ApiProxyLocalImpl.java:498) 
    at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.call(ApiProxyLocalImpl.java:452) 
    at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.call(ApiProxyLocalImpl.java:430) 
    at java.util.concurrent.Executors$PrivilegedCallable$1.run(Executors.java:463) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.util.concurrent.Executors$PrivilegedCallable.call(Executors.java:460) 
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:138) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) 
    at java.lang.Thread.run(Thread.java:619) 

請幫助我。在此先感謝 - 至尊康德

+0

這是一個有趣的問題。除了本地版本之外,它在生產中是否也會發生? – 2013-02-25 21:56:26

+0

嗨感謝您的回覆...是的,這個問題也在生產中。我應該從代碼中刪除元字段嗎? – 2013-02-26 07:42:12

回答

0

我不得不去爲com.google.appengine.api.files.GSFileOptions的源代碼(GAE Java SDK中1.8.1.1),才能找出一個有效的水桶名應該。

37行:this.fileName = FileServiceImpl.GS_FILESYSTEM_PREFIX +桶+ 「/」 +密鑰;

的Javadoc沒有提供關於桶的格式的任何信息。在這種情況下,請不要在您的存儲桶名稱末尾包含/ gs /前綴或/(如我在做的那樣)。如果您使用了其他API(如BlobStor API),這可能會令人困惑,因爲它們需要/ gs /前綴。

我得到了與1.8.1.1相同的異常和堆棧跟蹤,所以壞的桶名稱可能是原因。

此外,你可能想嘗試Google Cloud Storage Client Library

相關問題