0

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

4

2 に答える 2

1

Google Cloud Storage のエラーとエラー処理サービス アカウントのドキュメントをご覧ください。

403 は、ユーザーが要求を行う権限がなかったことを示します。GCE インスタンスで実行している場合、バケットへの書き込み権限を持つサービス アカウントでコードが実行されていると思います。ローカルで実行する場合、同じことを行うには適切な資格情報を提供する必要があります。

于 2016-06-10T21:49:03.003 に答える