2016-09-19 5 views
0

:。すべてのアップロードの終わりに」Googleの「gsutil cp」コマンドは、転送されたファイルのチェックサムを実行します。 GoogleのJavaストレージAPIも同じですか? <a href="https://cloud.google.com/storage/docs/gsutil/commands/cp#checksum-validation" rel="nofollow">documentation on gsutil</a>から

またはgsutilののcpコマンドをダウンロードするには、それはソースファイルの計算チェックサムが/オブジェクトは、サービスが計算したチェックサムと一致することを検証し、チェックサムが一致しない場合は、gsutilの破損したオブジェクトが削除され、警告メッセージが表示されます。

そして、ここだ彼らのJavaのストレージAPI使用して、いくつかのsample code

public static void uploadFile(String name, String contentType, File file, String bucketName) 
    throws IOException, GeneralSecurityException { 
    InputStreamContent contentStream = new InputStreamContent(
      contentType, new FileInputStream(file)); 
    // Setting the length improves upload performance 
    contentStream.setLength(file.length()); 
    StorageObject objectMetadata = new StorageObject() 
     // Set the destination object name 
     .setName(name) 
     // Set the access control list to publicly read-only 
     .setAcl(Arrays.asList(
      new ObjectAccessControl().setEntity("allUsers").setRole("READER"))); 

    // Do the insert 
    Storage client = StorageFactory.getService(); 
    Storage.Objects.Insert insertRequest = client.objects().insert(
      bucketName, objectMetadata, contentStream); 

    insertRequest.execute(); 
} 

を実行するために必要なチェックサムですか?私はそれを手動で行うべきですか?

答えて

3

すべてのアップロードとダウンロードでチェックサムを計算し、計算したチェックサムがサービスと一致することを検証することをお勧めします。これによりクラウドへの/クラウドからの途中でデータが破損する可能性のあるクライアントまたはクライアントライブラリのバグから保護されます。

私はこのサンプルコードを更新し、チェックサムの計算を含むようにバグをオープンします。

関連する問題

 関連する問題