我使用 GCSService 在 GoogleCloudStorage 存储桶中写入文件,在在线实例上一切正常,但是当我想在本地开发服务器上测试我的代码时,不可能在存储桶中写入(模拟本地存储桶,如数据存储)。额外的困难我尝试使用来自胖客户端的远程 API 在我的本地服务器上编写,我在整个网络上搜索我没有找到我的答案。当我调用我的 createOrUpdate() 方法时,我有这个异常:
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();
}
使用相同的代码,我可以毫无问题地在 DataStore 中编写,这只是存储问题。