com.google.cloud.storage.Blob.reload()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(2.5k)|赞(0)|评价(0)|浏览(91)

本文整理了Java中com.google.cloud.storage.Blob.reload()方法的一些代码示例,展示了Blob.reload()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Blob.reload()方法的具体详情如下:
包路径:com.google.cloud.storage.Blob
类名称:Blob
方法名:reload

Blob.reload介绍

[英]Fetches current blob's latest information. Returns null if the blob does not exist.

Example of getting the blob's latest information, if its generation does not match the Blob#getGeneration() value, otherwise a StorageException is thrown.

Blob latestBlob = blob.reload(BlobSourceOption.generationNotMatch());}

[中]获取当前blob的最新信息。如果blob不存在,则返回null。
获取blob最新信息的示例,如果其生成与blob#getGeneration()值不匹配,则会引发StorageException。

Blob latestBlob = blob.reload(BlobSourceOption.generationNotMatch());}

代码示例

代码示例来源:origin: googleapis/google-cloud-java

/**
 * Example of getting the blob's latest information, if its generation does not match the {@link
 * Blob#getGeneration()} value, otherwise a {@link StorageException} is thrown.
 */
// [TARGET reload(BlobSourceOption...)]
public Blob reload() {
 // [START reload]
 Blob latestBlob = blob.reload(BlobSourceOption.generationNotMatch());
 if (latestBlob == null) {
  // the blob was not found
 }
 // [END reload]
 return latestBlob;
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testReloadNull() throws Exception {
 initializeExpectedBlob(1);
 expect(storage.getOptions()).andReturn(mockOptions);
 expect(storage.get(BLOB_INFO.getBlobId(), new Storage.BlobGetOption[0])).andReturn(null);
 replay(storage);
 initializeBlob();
 Blob reloadedBlob = blob.reload();
 assertNull(reloadedBlob);
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testReload() throws Exception {
 initializeExpectedBlob(2);
 Blob expectedReloadedBlob = expectedBlob.toBuilder().setCacheControl("c").build();
 expect(storage.getOptions()).andReturn(mockOptions);
 expect(storage.get(BLOB_INFO.getBlobId(), new Storage.BlobGetOption[0]))
   .andReturn(expectedReloadedBlob);
 replay(storage);
 initializeBlob();
 Blob updatedBlob = blob.reload();
 assertEquals(expectedReloadedBlob, updatedBlob);
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testReloadWithOptions() throws Exception {
 initializeExpectedBlob(2);
 Blob expectedReloadedBlob = expectedBlob.toBuilder().setCacheControl("c").build();
 Storage.BlobGetOption[] options = {Storage.BlobGetOption.metagenerationMatch(42L)};
 expect(storage.getOptions()).andReturn(mockOptions);
 expect(storage.get(BLOB_INFO.getBlobId(), options)).andReturn(expectedReloadedBlob);
 replay(storage);
 initializeBlob();
 Blob updatedBlob = blob.reload(BlobSourceOption.metagenerationMatch());
 assertEquals(expectedReloadedBlob, updatedBlob);
}

相关文章