我使用GCSService在GoogleCloudStorage存储桶中写入文件,所有这些都可以在线实例正常工作,但是当我想在本地开发服务器上测试我的代码时,不可能写入一个存储桶(像数据存储一样模拟本地存储区)。 额外的困难我试图写在我的本地服务器与胖客户端的远程API,我在网上搜索我没有找到我的答案。 当我打电话给我的createOrUpdate()方法,我有这样的例外:Google App引擎Java API在本地开发服务器上写入存储桶不起作用
com.google.appengine.tools.cloudstorage.NonRetriableException: java.lang.RuntimeException: Server replied with 403, verify ACLs are set correctly on the object and bucket: Request: POST https://storage.googleapis.com/InstanceName/FileInfos
它似乎试图在我的网上桶写...
GcsService gcsService = GcsServiceFactory.createGcsService(RetryParams.getDefaultInstance());
...
RemoteApiOptions destination = RemoteConnection.connect(destinationServer);
RemoteApiInstaller destinationInstaller = new RemoteApiInstaller();
destinationInstaller.install(destination);
try
{
GcsOutputChannel outputChannel = gcsService.createOrReplace(new GcsFilename(destinationBucketServer, fileInfo.getFilename()),
GcsFileOptions.getDefaultInstance());
outputChannel.write(ByteBuffer.wrap(data));
outputChannel.close();
}
catch (Exception e)
{
....
}
finally
{
buffer.flush();
destinationInstaller.uninstall();
}
用同样的代码,我可以在数据存储中没有写任何问题,这只是一个存储问题。
是的我知道403是什么意思,但是我可以在本地存储桶中配置本地ACL,但是我没有发现任何有关此配置的信息。在例外情况下,有远程URL POST https://storage.googleapis.com/InstanceName/FileInfos喜欢它尝试在线上传。 感谢您的回答 – Benjyyyyy
除此之外,我使用开发服务器凭证连接到本地服务器,我在这里错过了什么?为什么此代码不提供访问权限? new RemoteApiOptions()。server(server.getAddress(),server.getPort())。useDevelopmentServerCredential(); – Benjyyyyy