我在尝试确定 Google Cloud Storage 中是否存在“目录/文件夹”时遇到问题。
我知道技术上没有“目录”或“文件夹”的概念,但我需要检查是否存在特定的前缀。
这是我检测 Blob 是否存在且工作正常的方法:
public boolean doesFileExist(String bucket, String prefix) {
Blob blob = storage.get(bucket, prefix);
return blob != null;
}
Run Code Online (Sandbox Code Playgroud)
当使用带有扩展名的实际文件名时,这似乎有效。但是,将它用于类似的操作folder/
是行不通的。
有什么建议?