3

我在本地和生产中收到以下错误。我正在使用 SDK1.6.3。@production 我还在“google api 控制台”的团队选项卡中添加了 XXXXXXXX@appspot.gserviceaccount.com。

  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)

请帮帮我。在此先感谢 - Shri Kant

4

2 回答 2

0

请升级到最新版本的 Java SDK(2013 年 5 月 18 日为 1.8.0):https ://developers.google.com/appengine/downloads#Google_App_Engine_SDK_for_Java

当前版本的 SDK 不再包含您在错误中列出的堆栈跟踪:

at com.google.appengine.api.files.dev.LocalFileService.throwError(LocalFileService.java:196)
于 2013-05-18T22:47:12.403 回答
0

我必须查看 com.google.appengine.api.files.GSFileOptions (gae java sdk 1.8.1.1) 的源代码才能找出有效的存储桶名称应该是什么。

第37行:this.fileName = FileServiceImpl.GS_FILESYSTEM_PREFIX + bucket + "/" + key;

Javadoc 不提供有关存储桶格式的任何信息。在这种情况下,不要在您的存储桶名称中包含 /gs/ 前缀或 / 结尾(就像我所做的那样。)如果您使用过其他 API(例如BlobStor API),这可能会令人困惑,因为它们需要 /gs/字首。

我得到了与 1.8.1.1 相同的异常和堆栈跟踪,因此错误的存储桶名称可能是原因。

此外,您可能想尝试Google Cloud Storage Client Library

于 2013-07-07T21:24:43.993 回答