我正在以下列格式在谷歌云中存储对象
bucketname/UUID/object
例如,我在谷歌云中有一个对象,存储为
roshanbucket/1fa0e7b4-b551-4e5c-a491-8d86f06a1eef/test.txt
这是我用来返回对象名称的方法
public String getFileName(String bucketName, String uuid) {
final String[] fileName = {null};
Page<Blob> blobs = storage.list(bucketName, BlobListOption.prefix(uuid));
blobs.iterateAll().forEach(
blob -> fileName[0] = blob.getName()//.substring(blob.getName().lastIndexOf('/') + 1)
);
return fileName[0];
}
这是测试方法
@Test
public void testGetFileName(){
String fileName = googleCloudStorage.getFileName("roshanbucket", "1fa0e7b4-b551-4e5c-a491-8d86f06a1eef");
System.out.println(fileName);
}
当我运行测试时,它给了我以下错误
java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V
at com.google.cloud.storage.StorageImpl.optionMap(StorageImpl.java:1279)
at com.google.cloud.storage.StorageImpl.optionMap(StorageImpl.java:1268)
at com.google.cloud.storage.StorageImpl.optionMap(StorageImpl.java:1301)
at com.google.cloud.storage.StorageImpl.list(StorageImpl.java:306)
at services.fileserver.GoogleCloudStorage.getFileName(GoogleCloudStorage.java:76)
at services.fileserver.GoogleCloudStorageTest.testDownloadLink(GoogleCloudStorageTest.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
如何解决此问题?
慕雪6442864
米脂
波斯汪
相关分类