Google 的 'gsutil cp' 命令对传输的文件运行校验和。 Google 的 java 存储 API 也一样吗?

Google's 'gsutil cp' command runs a checksum on the file transferred. Does Google's java storage API do the same?

来自documentation on gsutil:

"At the end of every upload or download the gsutil cp command validates that the checksum it computes for the source file/object matches the checksum the service computes. If the checksums do not match, gsutil will delete the corrupted object and print a warning message."

还有一些 sample code 使用他们的 java 存储空间 API:

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();
}

是否需要执行校验和?我应该手动做吗?

我们建议计算所有上传和下载的校验和,并验证您计算的校验和是否与服务具有的校验和相匹配。这样做可以保护您免受客户端或客户端库错误的影响,这些错误可能会破坏 to/from 云中的数据。

我将打开一个错误来更新示例代码,包括计算校验和。