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 に書き込むことができます。これは、ストレージの問題のみです。