首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google App engine Java API写入本地开发服务器的存储桶中不起作用

Google App engine Java API写入本地开发服务器的存储桶中不起作用
EN

Stack Overflow用户
提问于 2016-06-09 22:07:13
回答 2查看 197关注 0票数 0

我使用GCSService在GoogleCloudStorage存储桶中写入文件,所有这些在联机实例中都工作得很好,但是当我想在本地开发服务器上测试我的代码时,不可能在存储桶中写入(类似于数据存储的模拟本地存储桶)。额外的困难我尝试用胖客户端的远程API在我的本地服务器上写,我在web上到处搜索都没有找到我的答案。

代码语言:javascript
复制
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

代码语言:javascript
复制
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();
}

使用相同的代码,我可以用DataStore编写,没有任何问题,这只是一个存储问题。

EN

回答 2

Stack Overflow用户

发布于 2016-06-11 05:49:03

请参阅Google Cloud Storage Errors and Error HandlingService Account文档。

403表示用户未被授权发出请求。当在您的GCE实例上运行时,我猜测您的代码运行在一个对您的存储桶具有写权限的服务帐户中。在本地运行时,您必须提供适当的凭据才能执行相同的操作。

票数 1
EN

Stack Overflow用户

发布于 2016-06-16 17:13:13

我明白了为什么这不起作用,实际上通过RemoteAPI调用GCS并不是写在本地服务器上,而是写在在线存储桶上。这就是为什么我没有正确的ACL,我的代码尝试连接到云存储。但是现在我不知道如何强制GCSService在我的本地服务器上写入。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37728287

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档